aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2025-11-29 18:59:29 -0500
committerB. Watson <urchlay@slackware.uk>2025-11-29 18:59:29 -0500
commitbe8cd823dbd9b27889421bb1dc70217d39752663 (patch)
treeeb8c5efc190e78368571aa31af3bd602e2763bd1 /src
parent557f9de3358651663408eee2b03dd5dca26e950c (diff)
downloadalftools-be8cd823dbd9b27889421bb1dc70217d39752663.tar.gz
alf: Speed up match_token() slightly. Still too slow.
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;