diff options
| author | B. Watson <urchlay@slackware.uk> | 2025-11-26 07:22:21 -0500 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2025-11-26 07:22:21 -0500 |
| commit | 6603ee7739db9db34e3acf8bb3f4c6219fb50ee1 (patch) | |
| tree | 539d62d148c7f27c7c802f37bdec023e55f8bed2 | |
| parent | 10865a35bc9cce9a24ed3fed120ba4d57cb5e963 (diff) | |
| download | unalf-6603ee7739db9db34e3acf8bb3f4c6219fb50ee1.tar.gz | |
Speed up match_token() by ~5x.
| -rw-r--r-- | src/alf.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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; } |
