aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2025-11-26 07:22:21 -0500
committerB. Watson <urchlay@slackware.uk>2025-11-26 07:22:21 -0500
commit6603ee7739db9db34e3acf8bb3f4c6219fb50ee1 (patch)
tree539d62d148c7f27c7c802f37bdec023e55f8bed2
parent10865a35bc9cce9a24ed3fed120ba4d57cb5e963 (diff)
downloadunalf-6603ee7739db9db34e3acf8bb3f4c6219fb50ee1.tar.gz
Speed up match_token() by ~5x.
-rw-r--r--src/alf.c3
1 files changed, 3 insertions, 0 deletions
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;
}