Manually perform inlining & partial redundancy elimination to reduce calls
to FcValueListPtrU. Only invoke strlen() when really necessary. reviewed by: plam reviewed by: plam
This commit is contained in:
parent
8c24aa6b45
commit
adac22f290
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
||||||
|
2005-11-21 Dirk Mueller <dmueller@suse.com>
|
||||||
|
reviewed by: plam
|
||||||
|
|
||||||
|
* src/fcmatch.c (FcCompareValueList):
|
||||||
|
|
||||||
|
Manually perform inlining & partial redundancy elimination to
|
||||||
|
reduce calls to FcValueListPtrU.
|
||||||
|
|
||||||
|
2005-11-21 Dirk Mueller <dmueller@suse.com>
|
||||||
|
reviewed by: plam
|
||||||
|
|
||||||
|
* src/fcstr.c (FcStrFree, FcStrCaseWalkerInit, FcStrCaseWalkerLong,
|
||||||
|
FcStrCaseWalkerNext, FcStrCaseWalkerNextIgnoreBlanks):
|
||||||
|
|
||||||
|
Only invoke strlen() when really necessary.
|
||||||
|
|
||||||
2005-11-19 Matthias Clasen <mclasen@redhat.com>
|
2005-11-19 Matthias Clasen <mclasen@redhat.com>
|
||||||
reviewed by: plam
|
reviewed by: plam
|
||||||
|
|
||||||
|
|
|
@ -254,7 +254,8 @@ FcCompareValueList (const char *object,
|
||||||
double *value,
|
double *value,
|
||||||
FcResult *result)
|
FcResult *result)
|
||||||
{
|
{
|
||||||
FcValueListPtr v1, v2;
|
FcValueListPtr v1, v2;
|
||||||
|
FcValueList *v1_ptrU, *v2_ptrU;
|
||||||
double v, best, bestStrong, bestWeak;
|
double v, best, bestStrong, bestWeak;
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
@ -336,15 +337,15 @@ FcCompareValueList (const char *object,
|
||||||
bestStrong = 1e99;
|
bestStrong = 1e99;
|
||||||
bestWeak = 1e99;
|
bestWeak = 1e99;
|
||||||
j = 0;
|
j = 0;
|
||||||
for (v1 = v1orig; FcValueListPtrU(v1);
|
for (v1 = v1orig, v1_ptrU = FcValueListPtrU(v1); v1_ptrU;
|
||||||
v1 = FcValueListPtrU(v1)->next)
|
v1 = FcValueListPtrU(v1)->next, v1_ptrU = FcValueListPtrU(v1))
|
||||||
{
|
{
|
||||||
for (v2 = v2orig; 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) (_FcMatchers[i].object,
|
||||||
&FcValueListPtrU(v1)->value,
|
&v1_ptrU->value,
|
||||||
&FcValueListPtrU(v2)->value);
|
&v2_ptrU->value);
|
||||||
if (v < 0)
|
if (v < 0)
|
||||||
{
|
{
|
||||||
*result = FcResultTypeMismatch;
|
*result = FcResultTypeMismatch;
|
||||||
|
@ -356,10 +357,10 @@ FcCompareValueList (const char *object,
|
||||||
if (v < best)
|
if (v < best)
|
||||||
{
|
{
|
||||||
if (bestValue)
|
if (bestValue)
|
||||||
*bestValue = FcValueCanonicalize(&FcValueListPtrU(v2)->value);
|
*bestValue = FcValueCanonicalize(&v2_ptrU->value);
|
||||||
best = v;
|
best = v;
|
||||||
}
|
}
|
||||||
if (FcValueListPtrU(v1)->binding == FcValueBindingStrong)
|
if (v1_ptrU->binding == FcValueBindingStrong)
|
||||||
{
|
{
|
||||||
if (v < bestStrong)
|
if (v < bestStrong)
|
||||||
bestStrong = v;
|
bestStrong = v;
|
||||||
|
|
|
@ -74,7 +74,6 @@ FcStrFree (FcChar8 *s)
|
||||||
typedef struct _FcCaseWalker {
|
typedef struct _FcCaseWalker {
|
||||||
const FcChar8 *read;
|
const FcChar8 *read;
|
||||||
const FcChar8 *src;
|
const FcChar8 *src;
|
||||||
int len;
|
|
||||||
FcChar8 utf8[FC_MAX_CASE_FOLD_CHARS + 1];
|
FcChar8 utf8[FC_MAX_CASE_FOLD_CHARS + 1];
|
||||||
} FcCaseWalker;
|
} FcCaseWalker;
|
||||||
|
|
||||||
|
@ -83,7 +82,6 @@ FcStrCaseWalkerInit (const FcChar8 *src, FcCaseWalker *w)
|
||||||
{
|
{
|
||||||
w->src = src;
|
w->src = src;
|
||||||
w->read = 0;
|
w->read = 0;
|
||||||
w->len = strlen ((char *) src);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static FcChar8
|
static FcChar8
|
||||||
|
@ -91,8 +89,9 @@ FcStrCaseWalkerLong (FcCaseWalker *w, FcChar8 r)
|
||||||
{
|
{
|
||||||
FcChar32 ucs4;
|
FcChar32 ucs4;
|
||||||
int slen;
|
int slen;
|
||||||
|
int len = strlen((char*)w->src);
|
||||||
|
|
||||||
slen = FcUtf8ToUcs4 (w->src - 1, &ucs4, w->len + 1);
|
slen = FcUtf8ToUcs4 (w->src - 1, &ucs4, len + 1);
|
||||||
if (slen <= 0)
|
if (slen <= 0)
|
||||||
return r;
|
return r;
|
||||||
if (FC_MIN_FOLD_CHAR <= ucs4 && ucs4 <= FC_MAX_FOLD_CHAR)
|
if (FC_MIN_FOLD_CHAR <= ucs4 && ucs4 <= FC_MAX_FOLD_CHAR)
|
||||||
|
@ -131,7 +130,6 @@ FcStrCaseWalkerLong (FcCaseWalker *w, FcChar8 r)
|
||||||
|
|
||||||
/* consume rest of src utf-8 bytes */
|
/* consume rest of src utf-8 bytes */
|
||||||
w->src += slen - 1;
|
w->src += slen - 1;
|
||||||
w->len -= slen - 1;
|
|
||||||
|
|
||||||
/* read from temp buffer */
|
/* read from temp buffer */
|
||||||
w->utf8[dlen] = '\0';
|
w->utf8[dlen] = '\0';
|
||||||
|
@ -155,7 +153,6 @@ FcStrCaseWalkerNext (FcCaseWalker *w)
|
||||||
w->read = 0;
|
w->read = 0;
|
||||||
}
|
}
|
||||||
r = *w->src++;
|
r = *w->src++;
|
||||||
--w->len;
|
|
||||||
|
|
||||||
if ((r & 0xc0) == 0xc0)
|
if ((r & 0xc0) == 0xc0)
|
||||||
return FcStrCaseWalkerLong (w, r);
|
return FcStrCaseWalkerLong (w, r);
|
||||||
|
@ -178,7 +175,6 @@ FcStrCaseWalkerNextIgnoreBlanks (FcCaseWalker *w)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
r = *w->src++;
|
r = *w->src++;
|
||||||
--w->len;
|
|
||||||
} while (r == ' ');
|
} while (r == ' ');
|
||||||
|
|
||||||
if ((r & 0xc0) == 0xc0)
|
if ((r & 0xc0) == 0xc0)
|
||||||
|
|
Loading…
Reference in New Issue