The following code in FcConfigNormalizeFontDir () /* Ok, we didn't find it in fontDirs; let's add subdirs.... */ for (n = 0; n < config->fontDirs->num; n++) FcConfigAddFontDirSubdirs (config, config->fontDirs->strs[n]); adds the same subdirectories many times because config->fontDirs->num is getting bigger during the for loop. This causes many unnecessary opendir() and readdir() calls. I think one should end the for loop when the initial value of config->fontDirs->num is reached. All values in the list after the initial value of num are newly added subdirectories, there is no reason to scan them for subdirectories again. Patch attached.
diff -ru fontconfig-2.3.93.20060126.orig/src/fccfg.c fontconfig-2.3.93.20060126/src/fccfg.c --- fontconfig-2.3.93.20060126.orig/src/fccfg.c 2006-01-26 17:14:29.000000000 +0100 +++ fontconfig-2.3.93.20060126/src/fccfg.c 2006-01-26 18:22:43.000000000 +0100 @@ -432,7 +432,7 @@ /* If this is a bottleneck, we can cache the fontDir inodes. */ ino_t di; dev_t dd; - int n; + int n, nmax; struct stat s; if (stat ((char *)d, &s) == -1) @@ -448,7 +448,8 @@ } /* Ok, we didn't find it in fontDirs; let's add subdirs.... */ - for (n = 0; n < config->fontDirs->num; n++) + nmax = config->fontDirs->num; + for (n = 0; n < nmax; n++) FcConfigAddFontDirSubdirs (config, config->fontDirs->strs[n]); /* ... and try again. */
-- Mike FABIAN <mfabian@xxxxxxx> http://www.suse.de/~mfabian 睡眠不足はいい仕事の敵だ。
_______________________________________________ Fontconfig mailing list Fontconfig@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/fontconfig