Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
quasilyte opened this issue Jan 28, 2022 · 2 comments

Comments

@quasilyte
Copy link
Owner

quasilyte commented Jan 28, 2022

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.

@tdakkota
Copy link

tdakkota commented Feb 3, 2022

Why not suggest strings.ContainsRune?

@quasilyte
Copy link
Owner Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants