From be8cd823dbd9b27889421bb1dc70217d39752663 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 29 Nov 2025 18:59:29 -0500 Subject: alf: Speed up match_token() slightly. Still too slow. --- src/alf.c | 10 ++++++---- 1 file 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; -- cgit v1.2.3