Now the next question is if I have to handle runes. On Saturday, May 7, 2022 at 3:31:31 PM UTC-7 kortschak wrote:
> On Sat, 2022-05-07 at 15:18 -0700, Amnon wrote: > > The other interesting question is what algorithm we use to find the > > pattern in each line. > > Generally bytes.Contains uses Rabin-Karp. But as the pattern is the > > word "test" which is only 4 bytes long, > > a brute force search is used, using SSE type instructions where > > available. > > So the naive Go approach will give you a very fast execution. The > > main thing is to set up your scanner with a large buffer, to minimize > > the number > > of file system reads, and to avoid the newbie error of working with > > strings rather than []byte, and forcing the code to do vast numbers > > of > > unnecessary and expensive allocations. > > There is an interesting post from the author of grep that goes over > some of these details > https://lists.freebsd.org/pipermail/freebsd-current/2010-August/019310.html > . > > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/bcbf606e-d96d-4115-b14c-cb14f200aefan%40googlegroups.com.