Make the perf guys hate me a bit less: hoist the directory-name

FcConfigAcceptFont check for cached fonts up to directory cache read
    time, rather than running it for each font.
This commit is contained in:
Patrick Lam 2005-11-29 06:23:00 +00:00
parent 51af050992
commit 9fad72abaf
3 changed files with 13 additions and 4 deletions

View File

@ -1,3 +1,11 @@
2005-11-29 Patrick Lam <plam@mit.edu>
* src/fccfg.c (FcConfigBuildFonts):
* src/fccache.c (FcCacheReadDirs):
Make the perf guys hate me a bit less: hoist the directory-name
FcConfigAcceptFont check for cached fonts up to directory cache
read time, rather than running it for each font.
2005-11-29 Patrick Lam <plam@mit.edu> 2005-11-29 Patrick Lam <plam@mit.edu>
* src/fccfg.c (FcConfigBuildFonts): * src/fccfg.c (FcConfigBuildFonts):
* src/fcint.h: * src/fcint.h:

View File

@ -624,6 +624,9 @@ FcCacheReadDirs (FcConfig * config, FcGlobalCache * cache,
*/ */
while ((dir = FcStrListNext (list))) while ((dir = FcStrListNext (list)))
{ {
if (!FcConfigAcceptFilename (config, dir))
continue;
/* freed below */ /* freed below */
file = (FcChar8 *) malloc (strlen ((char *) dir) + 1 + FC_MAX_FILE_LEN + 1); file = (FcChar8 *) malloc (strlen ((char *) dir) + 1 + FC_MAX_FILE_LEN + 1);
if (!file) if (!file)

View File

@ -308,13 +308,11 @@ FcConfigBuildFonts (FcConfig *config)
for (i = 0; i < cached_fonts->nfont; i++) for (i = 0; i < cached_fonts->nfont; i++)
{ {
FcChar8 *cfn, *cfd; FcChar8 *cfn;
FcPatternGetString (cached_fonts->fonts[i], FC_FILE, 0, &cfn); FcPatternGetString (cached_fonts->fonts[i], FC_FILE, 0, &cfn);
cfd = (FcChar8 *)FcCacheFindBankDir (cached_fonts->fonts[i]->bank);
if (FcConfigAcceptFont (config, cached_fonts->fonts[i]) && if (FcConfigAcceptFont (config, cached_fonts->fonts[i]) &&
(cfn && FcConfigAcceptFilename (config, cfn)) && (cfn && FcConfigAcceptFilename (config, cfn)))
(cfd && FcConfigAcceptFilename (config, cfd)))
FcFontSetAdd (fonts, cached_fonts->fonts[i]); FcFontSetAdd (fonts, cached_fonts->fonts[i]);
cached_fonts->fonts[i] = 0; /* prevent free in FcFontSetDestroy */ cached_fonts->fonts[i] = 0; /* prevent free in FcFontSetDestroy */