Skip to content

Usually avoid the sort in WrappingRange::smallest_range_containing - #160674

Draft
scottmcm wants to merge 1 commit into
rust-lang:mainfrom
scottmcm:wait-what-happened
Draft

Usually avoid the sort in WrappingRange::smallest_range_containing#160674
scottmcm wants to merge 1 commit into
rust-lang:mainfrom
scottmcm:wait-what-happened

Conversation

@scottmcm

@scottmcm scottmcm commented Aug 7, 2026

Copy link
Copy Markdown
Member

I wasn't planning on touching this again, but I had a shower thought: we've been sorting these for a while because that's better than doing a quadratic check for usable wraparound ranges, but actually we often don't need to.

So long as the obvious min..=max range is small enough, we don't need to bother even looking for a wrapping range!

Now, I don't think this code is particularly hot -- you'd need lots of enums or particularly big ones before it would really matter -- but this does let us short-circuit for even fairly complex enums like mem::alignment.


  • I did not use an LLM to create a change in this PR.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 7, 2026
@scottmcm

scottmcm commented Aug 7, 2026

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-timer

Copy link
Copy Markdown
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 7, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 7, 2026
Usually avoid the sort in `WrappingRange::smallest_range_containing`
@rust-bors

rust-bors Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: d0d0b8b (d0d0b8bc325afb707fbc76fb45f437b5d32c6ce4)
Base parent: 88f7399 (88f7399cb4912680976e1c342ea7661b9dc84940)

@rust-timer

Copy link
Copy Markdown
Collaborator

Queued d0d0b8b with parent 88f7399, future comparison URL.
There are currently 10 preceding artifacts in the queue.
It will probably take at least ~10.9 hours until the benchmark run finishes.

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

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-perf Status: Waiting on a perf run to be completed. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants