Skip to content

Conversation

@gancerlory
Copy link
Contributor

Add an explicit bounds check before the while loop in PrefixSet::contains to help the compiler eliminate redundant per-iteration bounds checks.

Closes #19189

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

unsure if this is what you had in mind @malik672 ?

cc @DaniPopes

@malik672
Copy link
Contributor

unsure if this is what you had in mind @malik672 ?

cc @DaniPopes

Nope, something like this: #19189 (comment)

@gancerlory
Copy link
Contributor Author

gancerlory commented Oct 22, 2025

Nope, something like this: #19189 (comment)

Fixed by resetting index = 0 when out of bounds - this eliminates the bounds check while avoiding unnecessary backward scanning that index = len-1 would cause. Is this what you are looking for?

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

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

perf: elimnate bound check in contains while loop

3 participants