quasilyte/go-perfguard

Suggest strings.Contains instead of strings.ContainsAny for search of 1 char

quasilyte opened this issue · 2 comments

This may sound silly, but it's easy to implement.
The underlying issue is that ContainsAny is not always a fast choice.
See https://github.com/golang/go/issues/31321
TODO: do the actual benchmarking.

Why not suggest strings.ContainsRune?

I think initially I was concerned about this case: strings.ContainsAny(s, "ab") vs 2 calls of ContainsRune or one manually written loop, like in the referenced issue.