-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Use sort_by_cached_key where appropriate #49525
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
Changes from all commits
eacfb33
d3fe534
5cd0504
57eedba
1aa6152
2cc52f0
e7aa139
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -799,7 +799,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { | |
.collect(); | ||
|
||
// sort them by the name so we have a stable result | ||
names.sort_by_key(|n| n.as_str()); | ||
names.sort_by_cached_key(|n| n.as_str()); | ||
|
||
names | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1435,9 +1435,7 @@ impl<'a, 'tcx, 'rcx> AutoTraitFinder<'a, 'tcx, 'rcx> { | |||||||||||
// involved (impls rarely have more than a few bounds) means that it | ||||||||||||
// shouldn't matter in practice. | ||||||||||||
|
let len = self.len(); | |
if sz_u8 < sz_u16 && len <= ( u8::MAX as usize) { return sort_by_key!( u8, self, f) } | |
if sz_u16 < sz_u32 && len <= (u16::MAX as usize) { return sort_by_key!(u16, self, f) } | |
if sz_u32 < sz_usize && len <= (u32::MAX as usize) { return sort_by_key!(u32, self, f) } | |
sort_by_key!(usize, self, f) |
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.
That's another good point: I'll add that extra check in! (len == 2
could also be special cased to not allocate, as only one comparison will be executed, but that's a less likely case to encounter.)
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.
oh cute!