diff options
Diffstat (limited to 'src/xftglyphs.c')
-rw-r--r-- | src/xftglyphs.c | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/xftglyphs.c b/src/xftglyphs.c index 076acc5..10ab45e 100644 --- a/src/xftglyphs.c +++ b/src/xftglyphs.c @@ -957,8 +957,40 @@ XftFontCheckGlyph (Display *dpy, *nmissing = n; return FcTrue; } - else - return FcFalse; + + /* + * Make unloading faster by moving newly-referenced glyphs to the front + * of the list, leaving the less-used glyphs on the end. + */ + if (font->track_mem_usage + && font->total_inuse > 10 + && font->newest != FT_UINT_MAX + && font->newest != glyph) + { + XftGlyphUsage *xuse = (XftGlyphUsage *) xftg; + XftGlyphUsage *xtmp = (XftGlyphUsage *) font->glyphs[font->newest]; + XftGlyphUsage *xold; + XftGlyphUsage *xnew; + + /* delink */ + xold = (XftGlyphUsage *) font->glyphs[xuse->older]; + xnew = (XftGlyphUsage *) font->glyphs[xuse->newer]; + assert(xold != NULL); + assert(xnew != NULL); + xold->newer = xuse->newer; + xnew->older = xuse->older; + + /* relink */ + xnew = (XftGlyphUsage *) font->glyphs[xtmp->newer]; + assert(xnew != NULL); + xnew->older = glyph; + xuse->older = font->newest; + xuse->newer = xtmp->newer; + xtmp->newer = glyph; + + font->newest = glyph; + } + return FcFalse; } _X_EXPORT FcBool |