diff options
| author | B. Watson <urchlay@slackware.uk> | 2025-11-29 18:59:29 -0500 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2025-11-29 18:59:29 -0500 |
| commit | be8cd823dbd9b27889421bb1dc70217d39752663 (patch) | |
| tree | eb8c5efc190e78368571aa31af3bd602e2763bd1 | |
| parent | 557f9de3358651663408eee2b03dd5dca26e950c (diff) | |
| download | alftools-be8cd823dbd9b27889421bb1dc70217d39752663.tar.gz | |
alf: Speed up match_token() slightly. Still too slow.
| -rw-r--r-- | src/alf.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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; |
