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

perf: always check data when looking for last char of needle #180

Merged
merged 3 commits into from
Dec 10, 2024

Conversation

gurgunday
Copy link
Member

Forgot this one

Since we've now established that:

  • The lookbehind length is at max needleLength - 1, we have in the beginning pos = -lookbehind_size >= -(needleLength - 1)
  • And since we start by checking the last character, that last char will always be in data as pos + needleLength - 1 >= 0, and pos values equal to and larger than 0 correspond to the incoming data rather than the lookbehind, so we can safely remove the method

In short, ch will always be in data

@gurgunday gurgunday requested review from zekth, climba03003 and a team December 4, 2024 11:33
Copy link
Member

@zekth zekth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✌️

@gurgunday gurgunday merged commit fb4d05a into master Dec 10, 2024
13 checks passed
@gurgunday gurgunday deleted the lookup branch December 10, 2024 18:11
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

Successfully merging this pull request may close these issues.

2 participants