diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-08-21 09:12:35 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-08-25 12:15:18 -0400 |
commit | 7deb07e38e31da787875cb65db2ecb0dc0d5807f (patch) | |
tree | 6c158dce0f1350b8efe04b49d6a7ab285d27e67a /src | |
parent | 09729c9032e66da30c24d8268e444b2e6dd0e0d7 (diff) |
Speed up FcCompareLang and FcCompareBool
Avoid FcCanonicalize here too.
Diffstat (limited to 'src')
-rw-r--r-- | src/fcmatch.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/fcmatch.c b/src/fcmatch.c index 289204e..16d03de 100644 --- a/src/fcmatch.c +++ b/src/fcmatch.c @@ -104,30 +104,27 @@ static double FcCompareLang (const FcValue *v1, const FcValue *v2, FcValue *bestValue) { FcLangResult result; - FcValue value1 = FcValueCanonicalize(v1), value2 = FcValueCanonicalize(v2); - switch ((int) value1.type) { + switch ((int) v1->type) { case FcTypeLangSet: - switch ((int) value2.type) { + switch ((int) v2->type) { case FcTypeLangSet: - result = FcLangSetCompare (value1.u.l, value2.u.l); + result = FcLangSetCompare (FcValueLangSet (v1), FcValueLangSet (v2)); break; case FcTypeString: - result = FcLangSetHasLang (value1.u.l, - value2.u.s); + result = FcLangSetHasLang (FcValueLangSet (v1), FcValueString (v2)); break; default: return -1.0; } break; case FcTypeString: - switch ((int) value2.type) { + switch ((int) v2->type) { case FcTypeLangSet: - result = FcLangSetHasLang (value2.u.l, value1.u.s); + result = FcLangSetHasLang (FcValueLangSet (v2), FcValueString (v1)); break; case FcTypeString: - result = FcLangCompare (value1.u.s, - value2.u.s); + result = FcLangCompare (FcValueString (v1), FcValueString (v2)); break; default: return -1.0; @@ -154,10 +151,11 @@ FcCompareBool (const FcValue *v1, const FcValue *v2, FcValue *bestValue) if (v2->type != FcTypeBool || v1->type != FcTypeBool) return -1.0; + bestValue->type = FcTypeBool; if (v2->u.b != FcDontCare) - *bestValue = FcValueCanonicalize (v2); + bestValue->u.b = v2->u.b; else - *bestValue = FcValueCanonicalize (v1); + bestValue->u.b = v1->u.b; return (double) ((v2->u.b ^ v1->u.b) == 1); } |