Skip to content

Comment on Why GNU grep is Fastparent

Comments

Followed by:

> "Even long-winded users won't write Moby Dick into your <textarea>"

Which has most cases already much longer than those where the setup costs of BM are larger than the gain if the match is found on average halfway in to the text.

Typically you hit that point when the 'haystack' is about 2,000 characters and the 'needle' is longer than about 4 to 5, longer 'needles' or longer 'haystacks' would increase the advantage.

So the HTTP header one is probably one situation where you'd be quicker using brute force but in those other two instances it is very well possible that BM is already faster.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.