3 ms·
One trick you could try is: in find_longest_match, if you already have a match, check if the byte at match_maxlen matches before doing the linear compare off al
by jibsen 13y ago
One trick you could try is: in find_longest_match, if you already have a match, check if the byte at match_maxlen matches before doing the linear compare off all bytes up to it.
If that one byte does not match, the entire match has no chance of being longer than the current best (in this simple case).
- silentbicycle 13y agoGood idea! I'll try it out later, thanks. Kind of a variant of Boyer-Moore. I had thought about BM, but ruled it out because the search string length isn't fixed.
- silentbicycle 13y agoThat did speed things up a bit further: https://github.com/atomicobject/heatshrink/commit/38b8025895fd5a2b5955c3f64f79369fed965eb8 https://github.com/atomicobject/heatshrink/commit/38b8025895...