From 2f486f6584f3c0d6d1c7eadfbc56cd13a8f3122f Mon Sep 17 00:00:00 2001 From: Akira TAGOH Date: Wed, 15 Nov 2017 23:24:24 +0900 Subject: Don't call FcStat when the alias has already been added Similar changes to 3a3d6ea applies to fclist and fcmatch. --- src/fclist.c | 49 ++++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) (limited to 'src/fclist.c') diff --git a/src/fclist.c b/src/fclist.c index c78f55b..5f92a72 100644 --- a/src/fclist.c +++ b/src/fclist.c @@ -450,43 +450,38 @@ FcListAppend (FcListHashTable *table, { if (FcRefIsConst (&font->ref) && !strcmp (os->objects[o], FC_FILE)) { - struct stat statb; + FcChar8 *dir, *alias; + FcConfig *config = FcConfigGetCurrent (); /* FIXME: this may need to be exported as API? */ for (v = FcPatternEltValues (e); v->value.type != FcTypeString; v = FcValueListNext (v)); if (!v) goto bail2; - if (FcStat (FcValueString (&v->value), &statb) < 0) + dir = FcStrDirname (FcValueString (&v->value)); + if (FcHashTableFind (config->alias_table, dir, (void **) &alias)) { - FcChar8 *dir = FcStrDirname (FcValueString (&v->value)); - FcChar8 *alias; - FcConfig *config = FcConfigGetCurrent (); /* FIXME: this may need to be exported as API? */ - - if (FcHashTableFind (config->alias_table, dir, (void **) &alias)) + FcChar8 *base = FcStrBasename (FcValueString (&v->value)); + FcChar8 *s = FcStrBuildFilename (alias, base, NULL); + FcValue vv; + + FcStrFree (alias); + FcStrFree (base); + vv.type = FcTypeString; + vv.u.s = s; + if (!FcPatternAdd (bucket->pattern, + os->objects[o], + FcValueCanonicalize (&vv), + FcTrue)) { - FcChar8 *base = FcStrBasename (FcValueString (&v->value)); - FcChar8 *s = FcStrBuildFilename (alias, base, NULL); - FcValue vv; - - FcStrFree (alias); - FcStrFree (base); - vv.type = FcTypeString; - vv.u.s = s; - if (!FcPatternAdd (bucket->pattern, - os->objects[o], - FcValueCanonicalize (&vv), - FcTrue)) - { - FcStrFree (s); - FcStrFree (dir); - goto bail2; - } FcStrFree (s); FcStrFree (dir); - goto bail3; + goto bail2; } - else - FcStrFree (dir); + FcStrFree (s); + FcStrFree (dir); + goto bail3; } + else + FcStrFree (dir); } for (v = FcPatternEltValues(e), idx = 0; v; v = FcValueListNext(v), ++idx) -- cgit v1.2.1