-
Notifications
You must be signed in to change notification settings - Fork 149
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
Suggestion about is_valid function of LineBuffer struct #760
Comments
You are correct that if the second test (grapheme cluster boundary) is true the first one (UTF-8 char boundary) will always be true. The first check is local and only needs to check the byte at the index (or length), while the follow-on second check requires us to traverse the string. Without benchmarking with real data (that is most likely valid), there could be a questionable argument about short-circuiting saving us the work for the second check. Given that we expect valid data anyways, we could probably elide the first check. |
A little suggestion. It seems like first check and second check do the same check implicitly.
Is there a case where the first check is false and the second true ? What do you think ?
The text was updated successfully, but these errors were encountered: