Somewhat improves the performance but still need to think about for the situation
where both directories and fonts are in.
static FcStrSet *processed_dirs;
static int
static FcStrSet *processed_dirs;
static int
-scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, FcBool verbose, FcBool recursive, int *changed)
+scanDirs (FcStrList *list, FcConfig *config, FcBool force, FcBool really_force, FcBool verbose, FcBool recursive, int *changed, FcStrSet *updateDirs)
{
int ret = 0;
const FcChar8 *dir;
{
int ret = 0;
const FcChar8 *dir;
+ if (!recursive)
+ printf ("Re-scanning %s: ", dir);
+ else
+ printf ("%s: ", dir);
}
for (i = 0; i < FcCacheNumSubdir (cache); i++)
FcStrSetAdd (subdirs, FcCacheSubdir (cache, i));
}
for (i = 0; i < FcCacheNumSubdir (cache); i++)
FcStrSetAdd (subdirs, FcCacheSubdir (cache, i));
+ if (updateDirs && FcCacheNumSubdir (cache) > 0)
+ FcStrSetAdd (updateDirs, dir);
FcDirCacheUnload (cache);
FcDirCacheUnload (cache);
continue;
}
FcStrSetAdd (processed_dirs, dir);
continue;
}
FcStrSetAdd (processed_dirs, dir);
- ret += scanDirs (sublist, config, force, really_force, verbose, recursive, changed);
+ ret += scanDirs (sublist, config, force, really_force, verbose, recursive, changed, updateDirs);
FcStrListDone (sublist);
}
else
FcStrListDone (sublist);
}
else
int
main (int argc, char **argv)
{
int
main (int argc, char **argv)
{
+ FcStrSet *dirs, *updateDirs;
FcStrList *list;
FcBool verbose = FcFalse;
FcBool force = FcFalse;
FcStrList *list;
FcBool verbose = FcFalse;
FcBool force = FcFalse;
fprintf(stderr, "Cannot malloc\n");
return 1;
}
fprintf(stderr, "Cannot malloc\n");
return 1;
}
+
+ updateDirs = FcStrSetCreate ();
- ret = scanDirs (list, config, force, really_force, verbose, FcTrue, &changed);
+ ret = scanDirs (list, config, force, really_force, verbose, FcTrue, &changed, updateDirs);
/* Update the directory cache again to avoid the race condition as much as possible */
/* Update the directory cache again to avoid the race condition as much as possible */
- FcStrListFirst (list);
- ret += scanDirs (list, config, FcTrue, really_force, verbose, FcFalse, &changed);
+ list = FcStrListCreate (updateDirs);
+ if (list)
+ {
+ ret += scanDirs (list, config, FcTrue, really_force, verbose, FcFalse, &changed, NULL);
+ FcStrListDone (list);
+ }
/*
* Try to create CACHEDIR.TAG anyway.
/*
* Try to create CACHEDIR.TAG anyway.