Inline the *PtrU functions to gain perf. Remove unneeded params for the
FcCompare* functions. reviewed by: plam
This commit is contained in:
parent
3f9f24e077
commit
9ab79bdfb7
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2005-11-24 Dirk Mueller <dmueller@suse.com>
|
||||||
|
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 <dmueller@suse.com>
|
2005-11-24 Dirk Mueller <dmueller@suse.com>
|
||||||
reviewed by: plam
|
reviewed by: plam
|
||||||
|
|
||||||
|
|
31
src/fcint.h
31
src/fcint.h
|
@ -806,8 +806,11 @@ FcObjectSerialize (void);
|
||||||
const char *
|
const char *
|
||||||
FcObjectPtrU (FcObjectPtr p);
|
FcObjectPtrU (FcObjectPtr p);
|
||||||
|
|
||||||
int
|
static __inline__ int
|
||||||
FcObjectPtrCompare (FcObjectPtr a, FcObjectPtr b);
|
FcObjectPtrCompare (const FcObjectPtr a, const FcObjectPtr b)
|
||||||
|
{
|
||||||
|
return a - b;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FcObjectStaticNameFini (void);
|
FcObjectStaticNameFini (void);
|
||||||
|
@ -866,8 +869,28 @@ FcPatternNeededBytesAlign (void);
|
||||||
void *
|
void *
|
||||||
FcPatternDistributeBytes (FcCache * metadata, void * block_ptr);
|
FcPatternDistributeBytes (FcCache * metadata, void * block_ptr);
|
||||||
|
|
||||||
FcValueList *
|
/* please don't access these outside of fcpat.c! only visible so that
|
||||||
FcValueListPtrU(FcValueListPtr p);
|
* *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 *
|
FcPatternElt *
|
||||||
FcPatternEltU (FcPatternEltPtr pei);
|
FcPatternEltU (FcPatternEltPtr pei);
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
static double
|
static double
|
||||||
FcCompareNumber (const char *object, FcValue *value1, FcValue *value2)
|
FcCompareNumber (FcValue *value1, FcValue *value2)
|
||||||
{
|
{
|
||||||
double v1, v2, v;
|
double v1, v2, v;
|
||||||
|
|
||||||
|
@ -59,13 +59,13 @@ FcCompareNumber (const char *object, FcValue *value1, FcValue *value2)
|
||||||
}
|
}
|
||||||
|
|
||||||
static double
|
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;
|
return (double) FcStrCmpIgnoreCase (fc_value_string(v1), fc_value_string(v2)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static double
|
static double
|
||||||
FcCompareFamily (const char *object, FcValue *v1, FcValue *v2)
|
FcCompareFamily (FcValue *v1, FcValue *v2)
|
||||||
{
|
{
|
||||||
/* rely on the guarantee in FcPatternAddWithBinding that
|
/* rely on the guarantee in FcPatternAddWithBinding that
|
||||||
* families are always FcTypeString. */
|
* families are always FcTypeString. */
|
||||||
|
@ -79,7 +79,7 @@ FcCompareFamily (const char *object, FcValue *v1, FcValue *v2)
|
||||||
}
|
}
|
||||||
|
|
||||||
static double
|
static double
|
||||||
FcCompareLang (const char *object, FcValue *v1, FcValue *v2)
|
FcCompareLang (FcValue *v1, FcValue *v2)
|
||||||
{
|
{
|
||||||
FcLangResult result;
|
FcLangResult result;
|
||||||
FcValue value1 = FcValueCanonicalize(v1), value2 = FcValueCanonicalize(v2);
|
FcValue value1 = FcValueCanonicalize(v1), value2 = FcValueCanonicalize(v2);
|
||||||
|
@ -126,7 +126,7 @@ FcCompareLang (const char *object, FcValue *v1, FcValue *v2)
|
||||||
}
|
}
|
||||||
|
|
||||||
static double
|
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)
|
if (fc_storage_type(v2) != FcTypeBool || fc_storage_type(v1) != FcTypeBool)
|
||||||
return -1.0;
|
return -1.0;
|
||||||
|
@ -134,13 +134,13 @@ FcCompareBool (const char *object, FcValue *v1, FcValue *v2)
|
||||||
}
|
}
|
||||||
|
|
||||||
static double
|
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));
|
return (double) FcCharSetSubtractCount (fc_value_charset(v1), fc_value_charset(v2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static double
|
static double
|
||||||
FcCompareSize (const char *object, FcValue *value1, FcValue *value2)
|
FcCompareSize (FcValue *value1, FcValue *value2)
|
||||||
{
|
{
|
||||||
double v1, v2, v;
|
double v1, v2, v;
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ FcCompareSize (const char *object, FcValue *value1, FcValue *value2)
|
||||||
|
|
||||||
typedef struct _FcMatcher {
|
typedef struct _FcMatcher {
|
||||||
const char *object;
|
const char *object;
|
||||||
double (*compare) (const char *object, FcValue *value1, FcValue *value2);
|
double (*compare) (FcValue *value1, FcValue *value2);
|
||||||
int strong, weak;
|
int strong, weak;
|
||||||
} FcMatcher;
|
} FcMatcher;
|
||||||
|
|
||||||
|
@ -341,8 +341,7 @@ FcCompareValueList (const char *object,
|
||||||
for (v2 = v2orig, v2_ptrU = FcValueListPtrU(v2); FcValueListPtrU(v2);
|
for (v2 = v2orig, v2_ptrU = FcValueListPtrU(v2); FcValueListPtrU(v2);
|
||||||
v2 = FcValueListPtrU(v2)->next)
|
v2 = FcValueListPtrU(v2)->next)
|
||||||
{
|
{
|
||||||
v = (*_FcMatchers[i].compare) (_FcMatchers[i].object,
|
v = (*_FcMatchers[i].compare) (&v1_ptrU->value,
|
||||||
&v1_ptrU->value,
|
|
||||||
&v2_ptrU->value);
|
&v2_ptrU->value);
|
||||||
if (v < 0)
|
if (v < 0)
|
||||||
{
|
{
|
||||||
|
@ -414,39 +413,25 @@ FcCompare (FcPattern *pat,
|
||||||
i2 = 0;
|
i2 = 0;
|
||||||
while (i1 < pat->num && i2 < fnt->num)
|
while (i1 < pat->num && i2 < fnt->num)
|
||||||
{
|
{
|
||||||
i = FcObjectPtrCompare((FcPatternEltU(pat->elts)+i1)->object,
|
FcPatternElt *elt_i1 = FcPatternEltU(pat->elts)+i1;
|
||||||
(FcPatternEltU(fnt->elts)+i2)->object);
|
FcPatternElt *elt_i2 = FcPatternEltU(fnt->elts)+i2;
|
||||||
|
|
||||||
|
i = FcObjectPtrCompare(elt_i1->object, elt_i2->object);
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
i2++;
|
i2++;
|
||||||
else if (i < 0)
|
else if (i < 0)
|
||||||
i1++;
|
i1++;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!FcCompareValueList (FcObjectPtrU((FcPatternEltU(pat->elts)+i1)->object),
|
if (!FcCompareValueList (FcObjectPtrU(elt_i1->object),
|
||||||
(FcPatternEltU(pat->elts)+i1)->values,
|
elt_i1->values, elt_i2->values,
|
||||||
(FcPatternEltU(fnt->elts)+i2)->values,
|
0, value, result))
|
||||||
0,
|
|
||||||
value,
|
|
||||||
result))
|
|
||||||
return FcFalse;
|
return FcFalse;
|
||||||
i1++;
|
i1++;
|
||||||
i2++;
|
i2++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FcTrue;
|
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 *
|
FcPattern *
|
||||||
|
@ -783,8 +768,7 @@ FcFontSetSort (FcConfig *config,
|
||||||
FcPatternGet (p, FC_LANG, i, &patternLang) == FcResultMatch &&
|
FcPatternGet (p, FC_LANG, i, &patternLang) == FcResultMatch &&
|
||||||
FcPatternGet (nodeps[f]->pattern, FC_LANG, 0, &nodeLang) == FcResultMatch)
|
FcPatternGet (nodeps[f]->pattern, FC_LANG, 0, &nodeLang) == FcResultMatch)
|
||||||
{
|
{
|
||||||
double compare = FcCompareLang (FC_LANG, &patternLang,
|
double compare = FcCompareLang (&patternLang, &nodeLang);
|
||||||
&nodeLang);
|
|
||||||
if (compare >= 0 && compare < 2)
|
if (compare >= 0 && compare < 2)
|
||||||
{
|
{
|
||||||
if (FcDebug () & FC_DBG_MATCHV)
|
if (FcDebug () & FC_DBG_MATCHV)
|
||||||
|
|
12
src/fcname.c
12
src/fcname.c
|
@ -93,7 +93,8 @@ struct _FcObjectTypeList {
|
||||||
static const FcObjectTypeList _FcBaseObjectTypesList = {
|
static const FcObjectTypeList _FcBaseObjectTypesList = {
|
||||||
0,
|
0,
|
||||||
_FcBaseObjectTypes,
|
_FcBaseObjectTypes,
|
||||||
NUM_OBJECT_TYPES
|
NUM_OBJECT_TYPES,
|
||||||
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
static const FcObjectTypeList *_FcObjectTypes = &_FcBaseObjectTypesList;
|
static const FcObjectTypeList *_FcObjectTypes = &_FcBaseObjectTypesList;
|
||||||
|
@ -415,12 +416,6 @@ FcObjectUnserialize (FcCache metadata, void *block_ptr)
|
||||||
return block_ptr;
|
return block_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
FcObjectPtrCompare (const FcObjectPtr a, const FcObjectPtr b)
|
|
||||||
{
|
|
||||||
return a - b;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const FcConstant _FcBaseConstants[] = {
|
static const FcConstant _FcBaseConstants[] = {
|
||||||
{ (FcChar8 *) "thin", "weight", FC_WEIGHT_THIN, },
|
{ (FcChar8 *) "thin", "weight", FC_WEIGHT_THIN, },
|
||||||
{ (FcChar8 *) "extralight", "weight", FC_WEIGHT_EXTRALIGHT, },
|
{ (FcChar8 *) "extralight", "weight", FC_WEIGHT_EXTRALIGHT, },
|
||||||
|
@ -779,7 +774,6 @@ FcNameUnparseString (FcStrBuf *buf,
|
||||||
|
|
||||||
static FcBool
|
static FcBool
|
||||||
FcNameUnparseValue (FcStrBuf *buf,
|
FcNameUnparseValue (FcStrBuf *buf,
|
||||||
int bank,
|
|
||||||
FcValue *v0,
|
FcValue *v0,
|
||||||
FcChar8 *escape)
|
FcChar8 *escape)
|
||||||
{
|
{
|
||||||
|
@ -820,7 +814,7 @@ FcNameUnparseValueList (FcStrBuf *buf,
|
||||||
{
|
{
|
||||||
while (FcValueListPtrU(v))
|
while (FcValueListPtrU(v))
|
||||||
{
|
{
|
||||||
if (!FcNameUnparseValue (buf, v.bank, &FcValueListPtrU(v)->value, escape))
|
if (!FcNameUnparseValue (buf, &FcValueListPtrU(v)->value, escape))
|
||||||
return FcFalse;
|
return FcFalse;
|
||||||
if (FcValueListPtrU(v = FcValueListPtrU(v)->next))
|
if (FcValueListPtrU(v = FcValueListPtrU(v)->next))
|
||||||
if (!FcNameUnparseString (buf, (FcChar8 *) ",", 0))
|
if (!FcNameUnparseString (buf, (FcChar8 *) ",", 0))
|
||||||
|
|
22
src/fcpat.c
22
src/fcpat.c
|
@ -29,9 +29,9 @@
|
||||||
|
|
||||||
static FcPattern ** fcpatterns = 0;
|
static FcPattern ** fcpatterns = 0;
|
||||||
static int fcpattern_bank_count = 0, fcpattern_ptr, fcpattern_count;
|
static int fcpattern_bank_count = 0, fcpattern_ptr, fcpattern_count;
|
||||||
static FcPatternElt ** fcpatternelts = 0;
|
FcPatternElt ** fcpatternelts = 0;
|
||||||
static int fcpatternelt_ptr, fcpatternelt_count;
|
static int fcpatternelt_ptr, fcpatternelt_count;
|
||||||
static FcValueList ** fcvaluelists = 0;
|
FcValueList ** fcvaluelists = 0;
|
||||||
static int fcvaluelist_bank_count = 0, fcvaluelist_ptr, fcvaluelist_count;
|
static int fcvaluelist_bank_count = 0, fcvaluelist_ptr, fcvaluelist_count;
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
|
@ -1418,15 +1418,6 @@ FcPatternFini (void)
|
||||||
FcObjectStaticNameFini ();
|
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
|
static FcPatternEltPtr
|
||||||
FcPatternEltPtrCreateDynamic (FcPatternElt * e)
|
FcPatternEltPtrCreateDynamic (FcPatternElt * e)
|
||||||
{
|
{
|
||||||
|
@ -1827,15 +1818,6 @@ FcValueListUnserialize (FcCache metadata, void *block_ptr)
|
||||||
return 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
|
FcValueListPtr
|
||||||
FcValueListPtrCreateDynamic(FcValueList * p)
|
FcValueListPtrCreateDynamic(FcValueList * p)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue