]> git.wh0rd.org - fontconfig.git/commitdiff
Don't call FcPatternGetCharSet in FcSortWalk unless we need to (#17361)
authorBehdad Esfahbod <behdad@behdad.org>
Mon, 22 Sep 2008 22:51:11 +0000 (18:51 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Sat, 14 Feb 2009 00:54:00 +0000 (16:54 -0800)
src/fcmatch.c

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