HNHacker News
TopNewBestAskShowJobs

jo3_l

3 karma · joined September 11, 2026

submissionscomments
jo3_l··on Bitap: My favorite string matching algorithm
(OP here.) You're correct that for short patterns there's little advantage over the brute-force algorithm, and in fact the brute-force algorithm should actually be faster in many cases. Indeed the per-iteration comparison against the pattern in the brute-force algorithm is essentially a memcmp, which is vectorized and runs very fast on modern hardware. Consequently all mainstream programming languages that I know of just use the brute-force algorithm as a fallback when the pattern is short, as opposed to something more complicated like bitap.

I tried to be fairly careful to not overstate the performance benefits in the original post for this reason.