From 6603ee7739db9db34e3acf8bb3f4c6219fb50ee1 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 26 Nov 2025 07:22:21 -0500 Subject: Speed up match_token() by ~5x. --- src/alf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/alf.c b/src/alf.c index 7b27861..8fedb20 100644 --- a/src/alf.c +++ b/src/alf.c @@ -206,6 +206,9 @@ int match_token(int pos) { int i; for(i = curr_token - 1; i >= INIT_TOKEN; i--) { + /* if the first char doesn't match, don't bother with memcmp. + this is a 5x speedup (!) */ + if(input_buf[pos] != *(tokentab[i].start)) continue; if(memcmp(&input_buf[pos], tokentab[i].start, tokentab[i].length) == 0) return i; } -- cgit v1.2.3