]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcpat.c
Make FcCompareString and FcCompareFamily less expensive. Only add a value
[fontconfig.git] / src / fcpat.c
index a82fb6fb03a7223ee08286cab1f66f2de9714354..c37936f397133993fbaac14eb38382461551b9cb 100644 (file)
@@ -872,6 +872,13 @@ FcPatternAddWithBinding  (FcPattern            *p,
     if (value.type == FcTypeVoid)
        goto bail1;
 
+    /* quick and dirty hack to enable FcCompareFamily speedup:
+     * only allow strings to be added under the FC_FAMILY key.
+     * a better hack would use FcBaseObjectTypes to check all objects. */
+    if (FcObjectToPtr(object) == FcObjectToPtr(FC_FAMILY) &&
+        value.type != FcTypeString)
+        goto bail1;
+
     FcValueListPtrU(new)->value = value;
     FcValueListPtrU(new)->binding = binding;
     FcValueListPtrU(new)->next = FcValueListPtrCreateDynamic(0);