Don't call FcStat when the alias has already been added
Similar changes to 3a3d6ea applies to fclist and fcmatch.
This commit is contained in:
parent
665a5d3044
commit
2f486f6584
47
src/fclist.c
47
src/fclist.c
|
@ -450,43 +450,38 @@ FcListAppend (FcListHashTable *table,
|
||||||
{
|
{
|
||||||
if (FcRefIsConst (&font->ref) && !strcmp (os->objects[o], FC_FILE))
|
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));
|
for (v = FcPatternEltValues (e); v->value.type != FcTypeString; v = FcValueListNext (v));
|
||||||
if (!v)
|
if (!v)
|
||||||
goto bail2;
|
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 *base = FcStrBasename (FcValueString (&v->value));
|
||||||
FcChar8 *alias;
|
FcChar8 *s = FcStrBuildFilename (alias, base, NULL);
|
||||||
FcConfig *config = FcConfigGetCurrent (); /* FIXME: this may need to be exported as API? */
|
FcValue vv;
|
||||||
|
|
||||||
if (FcHashTableFind (config->alias_table, dir, (void **) &alias))
|
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 (s);
|
||||||
FcStrFree (dir);
|
FcStrFree (dir);
|
||||||
goto bail3;
|
goto bail2;
|
||||||
}
|
}
|
||||||
else
|
FcStrFree (s);
|
||||||
FcStrFree (dir);
|
FcStrFree (dir);
|
||||||
|
goto bail3;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
FcStrFree (dir);
|
||||||
}
|
}
|
||||||
for (v = FcPatternEltValues(e), idx = 0; v;
|
for (v = FcPatternEltValues(e), idx = 0; v;
|
||||||
v = FcValueListNext(v), ++idx)
|
v = FcValueListNext(v), ++idx)
|
||||||
|
|
|
@ -646,36 +646,33 @@ FcFontRenderPrepare (FcConfig *config,
|
||||||
if (FcRefIsConst (&font->ref) && fe->object == FC_FILE_OBJECT)
|
if (FcRefIsConst (&font->ref) && fe->object == FC_FILE_OBJECT)
|
||||||
{
|
{
|
||||||
FcValueListPtr l = FcPatternEltValues (fe);
|
FcValueListPtr l = FcPatternEltValues (fe);
|
||||||
struct stat statb;
|
FcChar8 *dir, *alias;
|
||||||
|
|
||||||
while (l->value.type != FcTypeString)
|
while (l->value.type != FcTypeString)
|
||||||
l = FcValueListNext (l);
|
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 *base = FcStrBasename (FcValueString (&l->value));
|
||||||
FcChar8 *alias;
|
FcChar8 *s = FcStrBuildFilename (alias, base, NULL);
|
||||||
|
FcValue v;
|
||||||
|
|
||||||
if (FcHashTableFind (config->alias_table, dir, (void **) &alias))
|
FcStrFree (alias);
|
||||||
{
|
FcStrFree (base);
|
||||||
FcChar8 *base = FcStrBasename (FcValueString (&l->value));
|
v.type = FcTypeString;
|
||||||
FcChar8 *s = FcStrBuildFilename (alias, base, NULL);
|
v.u.s = s;
|
||||||
FcValue v;
|
FcPatternObjectAddWithBinding (new, fe->object,
|
||||||
|
FcValueCanonicalize (&v),
|
||||||
FcStrFree (alias);
|
l->binding,
|
||||||
FcStrFree (base);
|
FcTrue);
|
||||||
v.type = FcTypeString;
|
FcStrFree (s);
|
||||||
v.u.s = s;
|
FcStrFree (dir);
|
||||||
FcPatternObjectAddWithBinding (new, fe->object,
|
goto bail0;
|
||||||
FcValueCanonicalize (&v),
|
|
||||||
l->binding,
|
|
||||||
FcTrue);
|
|
||||||
FcStrFree (s);
|
|
||||||
FcStrFree (dir);
|
|
||||||
goto bail0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
FcStrFree (dir);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
FcStrFree (dir);
|
||||||
}
|
}
|
||||||
FcPatternObjectListAdd (new, fe->object,
|
FcPatternObjectListAdd (new, fe->object,
|
||||||
FcValueListDuplicate (FcPatternEltValues (fe)),
|
FcValueListDuplicate (FcPatternEltValues (fe)),
|
||||||
|
|
Loading…
Reference in New Issue