Don't call FcPatternGetCharSet in FcSortWalk unless we need to (#17361)

This commit is contained in:
Behdad Esfahbod 2008-09-22 18:51:11 -04:00
parent 799691c901
commit 355ed50b18
1 changed files with 32 additions and 25 deletions

View File

@ -590,33 +590,40 @@ FcSortWalk (FcSortNode **n, int nnode, FcFontSet *fs, FcCharSet **cs, FcBool tri
while (nnode--) while (nnode--)
{ {
node = *n++; node = *n++;
if (FcPatternGetCharSet (node->pattern, FC_CHARSET, 0, &ncs) ==
FcResultMatch)
{
/*
* If this font isn't a subset of the previous fonts,
* add it to the list
*/
if (!trim || !*cs || !FcCharSetIsSubset (ncs, *cs))
{
if (trim || build_cs)
{
*cs = FcCharSetMerge (*cs, ncs);
if (*cs == NULL)
return FcFalse;
}
FcPatternReference (node->pattern); /*
if (FcDebug () & FC_DBG_MATCHV) * Only fetch node charset if we'd need it
{ */
printf ("Add "); if (trim || build_cs)
FcPatternPrint (node->pattern); {
} if (FcPatternGetCharSet (node->pattern, FC_CHARSET, 0, &ncs) !=
if (!FcFontSetAdd (fs, node->pattern)) FcResultMatch)
{ continue;
FcPatternDestroy (node->pattern); }
/*
* If this font isn't a subset of the previous fonts,
* add it to the list
*/
if (!trim || !*cs || !FcCharSetIsSubset (ncs, *cs))
{
if (trim || build_cs)
{
*cs = FcCharSetMerge (*cs, ncs);
if (*cs == NULL)
return FcFalse; return FcFalse;
} }
FcPatternReference (node->pattern);
if (FcDebug () & FC_DBG_MATCHV)
{
printf ("Add ");
FcPatternPrint (node->pattern);
}
if (!FcFontSetAdd (fs, node->pattern))
{
FcPatternDestroy (node->pattern);
return FcFalse;
} }
} }
} }