News for hackers. Stuff that matters.
Re:Go performance from version 1.2 to 1.18 by burntsushi on Friday February 04, 2022 @09:44AM (#30207340)
Go's regexp package even exposes a routine for this: https://pkg.go.dev/regexp#Regexp.LiteralPrefix

It's been a while since I've looked at the source code, but it is almost certainly already doing basic prefix literal optimizations.

The more advanced literal optimizations come into play when every match must start with one of a few possible characters or strings. Then you get into things like Aho-Corasick or fancy SIMD algorithms (Teddy).

Re:Go performance from version 1.2 to 1.18 by tedunangst on Friday February 04, 2022 @11:27AM (#30208914)
Oh, regarding rure go, the bugs note about using int is inaccurate. Go spec says max length of any object can be stored in int. You can't build a too big haystack.
Re:Go performance from version 1.2 to 1.18 by burntsushi on Friday February 04, 2022 @11:52AM (#30209272)
Ah that's right! Nice catch, thanks.