-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Safer sort partition #147378
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
base: master
Are you sure you want to change the base?
Safer sort partition #147378
Conversation
cc @orlp @Voultapher you may find this interesting (but you don't have to) |
I'm not sure that's true. Looking at for example this condition I'm all for reducing unsafe and a smaller code-size, with this PR as is, it might lead to confusing error messages and incorrect understanding of the code in the future. Maybe we can achieve a similar goal using the |
I mean only The additional checks piggyback on returning I still think it's an improvement over the current version of |
The arguments you present don't make sense to me.
|
d04d64f
to
ac2b421
Compare
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
ok, if reporting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a narrow review this seems reasonable to me, and I'll lean on #147378 (review) for it being ok more broadly. @bors r+ rollup=iffy (don't think it'll be a concern in the CI builds, but might be nice to have in an uncomplicated commit for bisecting) As an aside, I might steal the or-abort trick for some other places as a less-mono-needed version of some places I have asserts that can't actually fail but do help the optimizer. |
If the goal is to hopefully get a standalone merge, without an increased chance of CI failure, I think rollup=never is more appropriate. Iffy won't help if this ends up being the one iffy PR in a big rollup. @bors rollup=never |
This reduces amount of
unsafe
code inpartition()
, while generating essentially the same code.partition()
and functions calling it can only run into out-of-bounds issues if theis_less
function is buggy, so I've used coldpanic_on_ord_violation()
to replace various other panics/aborts. This slightly reduces code size, and gives a more relevant error message.Related to #144327