[PATCH libXfont] Fix Font lookup by fontfile is slow on certain patterns.
Matt Turner
mattst88 at gmail.com
Fri Dec 3 17:11:27 PST 2010
From: Takano Akio <aljee at hyper.cx>
https://bugs.freedesktop.org/show_bug.cgi?id=7832
---
src/fontfile/fontdir.c | 67 +++++++++++++-----------------------------------
1 files changed, 18 insertions(+), 49 deletions(-)
diff --git a/src/fontfile/fontdir.c b/src/fontfile/fontdir.c
index e052bb3..2f782fa 100644
--- a/src/fontfile/fontdir.c
+++ b/src/fontfile/fontdir.c
@@ -357,59 +357,28 @@ SetupWildMatch(FontTablePtr table, FontNamePtr pat,
static int
PatternMatch(char *pat, int patdashes, char *string, int stringdashes)
{
- char c,
- t;
+ int i;
+ char c;
- if (stringdashes < patdashes)
+ for (i = 0; (c = pat[i]) == string[i] || c == '?'; i++)
+ if (!c)
+ return 1;
+ if (c != '*')
return 0;
for (;;) {
- switch (c = *pat++) {
- case '*':
- if (!(c = *pat++))
- return 1;
- if (c == XK_minus) {
- patdashes--;
- for (;;) {
- while ((t = *string++) != XK_minus)
- if (!t)
- return 0;
- stringdashes--;
- if (PatternMatch(pat, patdashes, string, stringdashes))
- return 1;
- if (stringdashes == patdashes)
- return 0;
- }
- } else {
- for (;;) {
- while ((t = *string++) != c) {
- if (!t)
- return 0;
- if (t == XK_minus) {
- if (stringdashes-- < patdashes)
- return 0;
- }
- }
- if (PatternMatch(pat, patdashes, string, stringdashes))
- return 1;
- }
- }
- case '?':
- if (*string++ == XK_minus)
- stringdashes--;
- break;
- case '\0':
- return (*string == '\0');
- case XK_minus:
- if (*string++ == XK_minus) {
- patdashes--;
- stringdashes--;
- break;
- }
- return 0;
- default:
- if (c == *string++)
+ pat += i + 1;
+ if (!*pat)
+ return 1;
+ string += i;
+ for (;;) {
+ for (i = 0; (c = pat[i]) == string[i] || c == '?'; i++)
+ if (!c)
+ return 1;
+ if (c == '*')
break;
- return 0;
+ if (!*string)
+ return 0;
+ string++;
}
}
}
--
1.7.2.2
More information about the xorg-devel
mailing list