summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2017-11-15 23:24:24 +0900
committerAkira TAGOH <akira@tagoh.org>2017-11-20 17:37:23 +0530
commit2f486f6584f3c0d6d1c7eadfbc56cd13a8f3122f (patch)
tree78c42e6ee71b5863482e5c418de8021d64744e25 /src
parent665a5d30443cee9ef0eb977857ed2d19ed9f3cb6 (diff)
Don't call FcStat when the alias has already been added
Similar changes to 3a3d6ea applies to fclist and fcmatch.
Diffstat (limited to 'src')
-rw-r--r--src/fclist.c49
-rw-r--r--src/fcmatch.c47
2 files changed, 44 insertions, 52 deletions
diff --git a/src/fclist.c b/src/fclist.c
index c78f55b7..5f92a725 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)
diff --git a/src/fcmatch.c b/src/fcmatch.c
index 01e5fae4..5d30cc7e 100644
--- a/src/fcmatch.c
+++ b/src/fcmatch.c
@@ -646,36 +646,33 @@ FcFontRenderPrepare (FcConfig *config,
if (FcRefIsConst (&font->ref) && fe->object == FC_FILE_OBJECT)
{
FcValueListPtr l = FcPatternEltValues (fe);
- struct stat statb;
+ FcChar8 *dir, *alias;
while (l->value.type != FcTypeString)
l = FcValueListNext (l);
- if (FcStat (FcValueString (&l->value), &statb) < 0)
+ if (!l)
+ goto bail0;
+ dir = FcStrDirname (FcValueString (&l->value));
+ if (FcHashTableFind (config->alias_table, dir, (void **) &alias))
{
- FcChar8 *dir = FcStrDirname (FcValueString (&l->value));
- FcChar8 *alias;
-
- if (FcHashTableFind (config->alias_table, dir, (void **) &alias))
- {
- FcChar8 *base = FcStrBasename (FcValueString (&l->value));
- FcChar8 *s = FcStrBuildFilename (alias, base, NULL);
- FcValue v;
-
- FcStrFree (alias);
- FcStrFree (base);
- v.type = FcTypeString;
- v.u.s = s;
- FcPatternObjectAddWithBinding (new, fe->object,
- FcValueCanonicalize (&v),
- l->binding,
- FcTrue);
- FcStrFree (s);
- FcStrFree (dir);
- goto bail0;
- }
- else
- FcStrFree (dir);
+ FcChar8 *base = FcStrBasename (FcValueString (&l->value));
+ FcChar8 *s = FcStrBuildFilename (alias, base, NULL);
+ FcValue v;
+
+ FcStrFree (alias);
+ FcStrFree (base);
+ v.type = FcTypeString;
+ v.u.s = s;
+ FcPatternObjectAddWithBinding (new, fe->object,
+ FcValueCanonicalize (&v),
+ l->binding,
+ FcTrue);
+ FcStrFree (s);
+ FcStrFree (dir);
+ goto bail0;
}
+ else
+ FcStrFree (dir);
}
FcPatternObjectListAdd (new, fe->object,
FcValueListDuplicate (FcPatternEltValues (fe)),