aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/alf.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/alf.c b/src/alf.c
index 1d634ab..f3c4e0c 100644
--- a/src/alf.c
+++ b/src/alf.c
@@ -239,13 +239,15 @@ int match_token(int pos) {
/* inline memcmp replacement of sorts. I don't think it's really
faster than memcmp(), it only seems that way because there's
- no function call overhead. ~20% speedup. */
+ no function call overhead. ~20% speedup.
+ making it search backwards gives a further ~25% speedup.
+ */
len = t->length;
- p = &input_buf[pos];
- q = t->start;
+ p = &input_buf[pos] + len - 1;
+ q = t->start + len - 1;
while(len) {
if(*p != *q) break;
- p++; q++;
+ p--; q--;
len--;
}
if(!len) return i;