From: Patrick Lam Date: Fri, 25 Nov 2005 03:00:51 +0000 (+0000) Subject: Inline the *PtrU functions to gain perf. Remove unneeded params for the X-Git-Tag: fc-2_3_93~27 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=9ab79bdfb7f8bfbe108d1c676b361f69f6a5b043;p=fontconfig.git Inline the *PtrU functions to gain perf. Remove unneeded params for the FcCompare* functions. reviewed by: plam --- diff --git a/ChangeLog b/ChangeLog index 2acd9c4..afa95c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,14 @@ -2005-11-24 Dirk Mueller +2005-11-24 Dirk Mueller + reviewed by: plam + + * src/fcint.h: + * src/fcmatch.c (FcCompare*, FcFontSetSort): + * src/fcname.c (FcNameUnparseValue): + + Inline the *PtrU functions to gain perf. + Remove unneeded params for the FcCompare* functions. + +2005-11-24 Dirk Mueller reviewed by: plam * src/fcint.h, fontconfig/fontconfig.h: diff --git a/src/fcint.h b/src/fcint.h index e20589c..3019abb 100644 --- a/src/fcint.h +++ b/src/fcint.h @@ -806,8 +806,11 @@ FcObjectSerialize (void); const char * FcObjectPtrU (FcObjectPtr p); -int -FcObjectPtrCompare (FcObjectPtr a, FcObjectPtr b); +static __inline__ int +FcObjectPtrCompare (const FcObjectPtr a, const FcObjectPtr b) +{ + return a - b; +} void FcObjectStaticNameFini (void); @@ -866,8 +869,28 @@ FcPatternNeededBytesAlign (void); void * FcPatternDistributeBytes (FcCache * metadata, void * block_ptr); -FcValueList * -FcValueListPtrU(FcValueListPtr p); +/* please don't access these outside of fcpat.c! only visible so that + * *PtrU can be inlined. */ +extern FcValueList ** fcvaluelists; +extern FcPatternElt ** fcpatternelts; + +static __inline__ FcValueList * +FcValueListPtrU (FcValueListPtr pi) +{ + if (pi.bank == FC_BANK_DYNAMIC) + return pi.u.dyn; + + return &fcvaluelists[FcCacheBankToIndex(pi.bank)][pi.u.stat]; +} + +static __inline__ FcPatternElt * +FcPatternEltU (FcPatternEltPtr pei) +{ + if (pei.bank == FC_BANK_DYNAMIC) + return pei.u.dyn; + + return &fcpatternelts[FcCacheBankToIndex(pei.bank)][pei.u.stat]; +} FcPatternElt * FcPatternEltU (FcPatternEltPtr pei); diff --git a/src/fcmatch.c b/src/fcmatch.c index b0d4bf8..bc75aa6 100644 --- a/src/fcmatch.c +++ b/src/fcmatch.c @@ -28,7 +28,7 @@ #include static double -FcCompareNumber (const char *object, FcValue *value1, FcValue *value2) +FcCompareNumber (FcValue *value1, FcValue *value2) { double v1, v2, v; @@ -59,13 +59,13 @@ FcCompareNumber (const char *object, FcValue *value1, FcValue *value2) } static double -FcCompareString (const char *object, FcValue *v1, FcValue *v2) +FcCompareString (FcValue *v1, FcValue *v2) { return (double) FcStrCmpIgnoreCase (fc_value_string(v1), fc_value_string(v2)) != 0; } static double -FcCompareFamily (const char *object, FcValue *v1, FcValue *v2) +FcCompareFamily (FcValue *v1, FcValue *v2) { /* rely on the guarantee in FcPatternAddWithBinding that * families are always FcTypeString. */ @@ -79,7 +79,7 @@ FcCompareFamily (const char *object, FcValue *v1, FcValue *v2) } static double -FcCompareLang (const char *object, FcValue *v1, FcValue *v2) +FcCompareLang (FcValue *v1, FcValue *v2) { FcLangResult result; FcValue value1 = FcValueCanonicalize(v1), value2 = FcValueCanonicalize(v2); @@ -126,7 +126,7 @@ FcCompareLang (const char *object, FcValue *v1, FcValue *v2) } static double -FcCompareBool (const char *object, FcValue *v1, FcValue *v2) +FcCompareBool (FcValue *v1, FcValue *v2) { if (fc_storage_type(v2) != FcTypeBool || fc_storage_type(v1) != FcTypeBool) return -1.0; @@ -134,13 +134,13 @@ FcCompareBool (const char *object, FcValue *v1, FcValue *v2) } static double -FcCompareCharSet (const char *object, FcValue *v1, FcValue *v2) +FcCompareCharSet (FcValue *v1, FcValue *v2) { return (double) FcCharSetSubtractCount (fc_value_charset(v1), fc_value_charset(v2)); } static double -FcCompareSize (const char *object, FcValue *value1, FcValue *value2) +FcCompareSize (FcValue *value1, FcValue *value2) { double v1, v2, v; @@ -174,7 +174,7 @@ FcCompareSize (const char *object, FcValue *value1, FcValue *value2) typedef struct _FcMatcher { const char *object; - double (*compare) (const char *object, FcValue *value1, FcValue *value2); + double (*compare) (FcValue *value1, FcValue *value2); int strong, weak; } FcMatcher; @@ -341,8 +341,7 @@ FcCompareValueList (const char *object, for (v2 = v2orig, v2_ptrU = FcValueListPtrU(v2); FcValueListPtrU(v2); v2 = FcValueListPtrU(v2)->next) { - v = (*_FcMatchers[i].compare) (_FcMatchers[i].object, - &v1_ptrU->value, + v = (*_FcMatchers[i].compare) (&v1_ptrU->value, &v2_ptrU->value); if (v < 0) { @@ -414,39 +413,25 @@ FcCompare (FcPattern *pat, i2 = 0; while (i1 < pat->num && i2 < fnt->num) { - i = FcObjectPtrCompare((FcPatternEltU(pat->elts)+i1)->object, - (FcPatternEltU(fnt->elts)+i2)->object); + FcPatternElt *elt_i1 = FcPatternEltU(pat->elts)+i1; + FcPatternElt *elt_i2 = FcPatternEltU(fnt->elts)+i2; + + i = FcObjectPtrCompare(elt_i1->object, elt_i2->object); if (i > 0) i2++; else if (i < 0) i1++; else { - if (!FcCompareValueList (FcObjectPtrU((FcPatternEltU(pat->elts)+i1)->object), - (FcPatternEltU(pat->elts)+i1)->values, - (FcPatternEltU(fnt->elts)+i2)->values, - 0, - value, - result)) + if (!FcCompareValueList (FcObjectPtrU(elt_i1->object), + elt_i1->values, elt_i2->values, + 0, value, result)) return FcFalse; i1++; i2++; } } return FcTrue; -#if 0 - for (i1 = 0; i1 < pat->num; i1++) - { - for (i2 = 0; i2 < fnt->num; i2++) - { - if (!strcmp (pat->elts[i1].object, fnt->elts[i2].object)) - { - break; - } - } - } - return FcTrue; -#endif } FcPattern * @@ -783,8 +768,7 @@ FcFontSetSort (FcConfig *config, FcPatternGet (p, FC_LANG, i, &patternLang) == FcResultMatch && FcPatternGet (nodeps[f]->pattern, FC_LANG, 0, &nodeLang) == FcResultMatch) { - double compare = FcCompareLang (FC_LANG, &patternLang, - &nodeLang); + double compare = FcCompareLang (&patternLang, &nodeLang); if (compare >= 0 && compare < 2) { if (FcDebug () & FC_DBG_MATCHV) diff --git a/src/fcname.c b/src/fcname.c index bf265bd..2fc411f 100644 --- a/src/fcname.c +++ b/src/fcname.c @@ -93,7 +93,8 @@ struct _FcObjectTypeList { static const FcObjectTypeList _FcBaseObjectTypesList = { 0, _FcBaseObjectTypes, - NUM_OBJECT_TYPES + NUM_OBJECT_TYPES, + 0 }; static const FcObjectTypeList *_FcObjectTypes = &_FcBaseObjectTypesList; @@ -415,12 +416,6 @@ FcObjectUnserialize (FcCache metadata, void *block_ptr) return block_ptr; } -int -FcObjectPtrCompare (const FcObjectPtr a, const FcObjectPtr b) -{ - return a - b; -} - static const FcConstant _FcBaseConstants[] = { { (FcChar8 *) "thin", "weight", FC_WEIGHT_THIN, }, { (FcChar8 *) "extralight", "weight", FC_WEIGHT_EXTRALIGHT, }, @@ -779,7 +774,6 @@ FcNameUnparseString (FcStrBuf *buf, static FcBool FcNameUnparseValue (FcStrBuf *buf, - int bank, FcValue *v0, FcChar8 *escape) { @@ -820,7 +814,7 @@ FcNameUnparseValueList (FcStrBuf *buf, { while (FcValueListPtrU(v)) { - if (!FcNameUnparseValue (buf, v.bank, &FcValueListPtrU(v)->value, escape)) + if (!FcNameUnparseValue (buf, &FcValueListPtrU(v)->value, escape)) return FcFalse; if (FcValueListPtrU(v = FcValueListPtrU(v)->next)) if (!FcNameUnparseString (buf, (FcChar8 *) ",", 0)) diff --git a/src/fcpat.c b/src/fcpat.c index ad6afc0..b1bb595 100644 --- a/src/fcpat.c +++ b/src/fcpat.c @@ -29,9 +29,9 @@ static FcPattern ** fcpatterns = 0; static int fcpattern_bank_count = 0, fcpattern_ptr, fcpattern_count; -static FcPatternElt ** fcpatternelts = 0; +FcPatternElt ** fcpatternelts = 0; static int fcpatternelt_ptr, fcpatternelt_count; -static FcValueList ** fcvaluelists = 0; +FcValueList ** fcvaluelists = 0; static int fcvaluelist_bank_count = 0, fcvaluelist_ptr, fcvaluelist_count; static const char * @@ -1418,15 +1418,6 @@ FcPatternFini (void) FcObjectStaticNameFini (); } -FcPatternElt * -FcPatternEltU (FcPatternEltPtr pei) -{ - if (pei.bank == FC_BANK_DYNAMIC) - return pei.u.dyn; - - return &fcpatternelts[FcCacheBankToIndex(pei.bank)][pei.u.stat]; -} - static FcPatternEltPtr FcPatternEltPtrCreateDynamic (FcPatternElt * e) { @@ -1827,15 +1818,6 @@ FcValueListUnserialize (FcCache metadata, void *block_ptr) return block_ptr; } -FcValueList * -FcValueListPtrU (FcValueListPtr pi) -{ - if (pi.bank == FC_BANK_DYNAMIC) - return pi.u.dyn; - - return &fcvaluelists[FcCacheBankToIndex(pi.bank)][pi.u.stat]; -} - FcValueListPtr FcValueListPtrCreateDynamic(FcValueList * p) {