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

Use String#indexOf to find literals #7

Open
hyperpape opened this issue Aug 23, 2021 · 0 comments
Open

Use String#indexOf to find literals #7

hyperpape opened this issue Aug 23, 2021 · 0 comments

Comments

@hyperpape
Copy link
Owner

When searching for a literal in a string, we'd prefer to use String#indexOf, as it's implemented using Hotspot intrinsics, which ought to outperform anything we can write by hand.

Sadly, String#indexOf supports searching through the entire string, or searching through a suffix of the String, but does not seem to support searching from indices [m,n] where 0 < m < n < stringlength. This means that we can sometimes use these methods, but not always. Additionally, we may have to have separate code paths or runtime checks whether we're searching in a substring or the entire string.

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

No branches or pull requests

1 participant