Skip to content

Conversation

hkBst
Copy link
Member

@hkBst hkBst commented Sep 24, 2025

AFAICT we are only sorting to find duplicates, so unstable sort should work fine, and maybe is a tiny bit faster?

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 24, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 24, 2025

r? @nnethercote

rustbot has assigned @nnethercote.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Copy link
Contributor

@nnethercote nnethercote left a comment

Choose a reason for hiding this comment

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

How did you find this? I don't know if it's worth adding the PartialOrd/Ord impls.

View changes since this review

@hkBst
Copy link
Member Author

hkBst commented Sep 25, 2025

How did you find this?

I was looking at the code in #146980 because clippy triggers on the mutation of the loop variable, and was wondering about the manual Vec/FxHashSet subset (vec.all(set.contains())) and so wandered around a bit... then found myself wondering what kind of non-default-sort was happening. :D

I don't know if it's worth adding the PartialOrd/Ord impls.

I added them, because the sort_by_key(|x| x.0) made it look like it was doing a limited or special sorting different from the default sorting, but element 0 is literally its only element, so it is the default sorting. It seems clearer to me like this, but I'm not sure what the trade-off would be.

@nnethercote
Copy link
Contributor

I think the trade-offs are negligible... it's extremely unlikely to affect performance, and I find readability much the same either way. So it's a question of why bother?

@hkBst
Copy link
Member Author

hkBst commented Sep 26, 2025

Well, the way it's currently written, the sort is done with custom cmp, but the dedup uses default eq from partialEq. That inconsistency made me look into what was going on, so I know it can be a distraction. So for consistency I think it would be better if they both go the same way: either both use the same projection to element 0, or both use the default from PartialEq and Ord. My preference is for the latter option, but let me know which way you want to go.

@nnethercote
Copy link
Contributor

Eh, ok.

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Sep 29, 2025

📌 Commit 431ef03 has been approved by nnethercote

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 29, 2025
bors added a commit that referenced this pull request Sep 29, 2025
Rollup of 5 pull requests

Successful merges:

 - #146653 (improve diagnostics for empty attributes)
 - #146987 (impl Ord for params and use unstable sort)
 - #147101 (Use `Iterator::eq` and (dogfood) `eq_by` in compiler and library )
 - #147123 (Fix removed version numbers of `doc_auto_cfg` and `doc_cfg_hide`)
 - #147149 (add joboet to library review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit acd91e2 into rust-lang:master Sep 29, 2025
10 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Sep 29, 2025
rust-timer added a commit that referenced this pull request Sep 29, 2025
Rollup merge of #146987 - hkBst:sort-params-1, r=nnethercote

impl Ord for params and use unstable sort

AFAICT we are only sorting to find duplicates, so unstable sort should work fine, and maybe is a tiny bit faster?
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Sep 30, 2025
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#146653 (improve diagnostics for empty attributes)
 - rust-lang/rust#146987 (impl Ord for params and use unstable sort)
 - rust-lang/rust#147101 (Use `Iterator::eq` and (dogfood) `eq_by` in compiler and library )
 - rust-lang/rust#147123 (Fix removed version numbers of `doc_auto_cfg` and `doc_cfg_hide`)
 - rust-lang/rust#147149 (add joboet to library review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
github-actions bot pushed a commit to rust-lang/rust-analyzer that referenced this pull request Oct 2, 2025
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#146653 (improve diagnostics for empty attributes)
 - rust-lang/rust#146987 (impl Ord for params and use unstable sort)
 - rust-lang/rust#147101 (Use `Iterator::eq` and (dogfood) `eq_by` in compiler and library )
 - rust-lang/rust#147123 (Fix removed version numbers of `doc_auto_cfg` and `doc_cfg_hide`)
 - rust-lang/rust#147149 (add joboet to library review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

4 participants