Skip to content

Use Vec's binary search instead of hand-written one. #3021

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

Merged
merged 2 commits into from
Aug 9, 2023

Conversation

ttsugriy
Copy link
Contributor

@ttsugriy ttsugriy commented Aug 8, 2023

No description provided.

// We are too far right (offset is further left).
debug_assert!(candidate < right); // we are making progress
right = candidate;
std::cmp::Ordering::Greater
Copy link
Member

@RalfJung RalfJung Aug 9, 2023

Choose a reason for hiding this comment

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

Please preserve the comments inside the ifs here, they still seem helpful.

Also have the comment explain that Greater indicates "elem is greater than desired target".

@RalfJung
Copy link
Member

RalfJung commented Aug 9, 2023

Thanks, this looks much cleaner!

@bors r+

@bors
Copy link
Contributor

bors commented Aug 9, 2023

📌 Commit 5b8057e has been approved by RalfJung

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Aug 9, 2023

⌛ Testing commit 5b8057e with merge 646f5db...

@bors
Copy link
Contributor

bors commented Aug 9, 2023

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing 646f5db to master...

@bors bors merged commit 646f5db into rust-lang:master Aug 9, 2023
ttsugriy added a commit to ttsugriy/miri that referenced this pull request Aug 16, 2023
It's similar to rust-lang#3021 and
should improve maintainability.
ttsugriy added a commit to ttsugriy/miri that referenced this pull request Aug 16, 2023
It's similar to rust-lang#3021 and
should improve maintainability.
bors added a commit that referenced this pull request Aug 16, 2023
Replace hand-written binary search with Vec::binary_search_by.

It's similar to #3021 and should improve maintainability.
RalfJung pushed a commit to RalfJung/rust that referenced this pull request Aug 17, 2023
RalfJung pushed a commit to RalfJung/rust that referenced this pull request Aug 17, 2023
…Jung

Replace hand-written binary search with Vec::binary_search_by.

It's similar to rust-lang/miri#3021 and should improve maintainability.
lnicola pushed a commit to lnicola/rust-analyzer that referenced this pull request Apr 7, 2024
…Jung

Replace hand-written binary search with Vec::binary_search_by.

It's similar to rust-lang/miri#3021 and should improve maintainability.
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this pull request Apr 27, 2024
…Jung

Replace hand-written binary search with Vec::binary_search_by.

It's similar to rust-lang/miri#3021 and should improve maintainability.
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.

3 participants