-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Use Iterator::eq
and (dogfood) eq_by
in compiler and library
#147101
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
Conversation
Some changes occurred in compiler/rustc_attr_parsing Some changes occurred in compiler/rustc_builtin_macros/src/autodiff.rs cc @ZuseZ4 |
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
This comment has been minimized.
This comment has been minimized.
085e528
to
049a460
Compare
This comment has been minimized.
This comment has been minimized.
r? jdonszelmann |
/// `self` may contain more segments than the number matched against. | ||
pub fn starts_with(&self, segments: &[Symbol]) -> bool { | ||
segments.len() < self.len() && self.segments().zip(segments).all(|(a, b)| a.name == *b) | ||
segments.len() < self.len() |
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.
is this really better than what was there before? you still need to take() after the less-than check
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.
I'm not sure which version I like more, but it's definitely not a clear-cut improvement so I undid this change.
@rustbot author |
Reminder, once the PR becomes ready for a review, use |
049a460
to
f9d10c7
Compare
This comment has been minimized.
This comment has been minimized.
@rustbot ready |
r=me if you squash the two commits, don't quite see why the 2nd commit is separate from the first |
@rustbot author |
f9d10c7
to
68a7c25
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. |
The separation was just to make reviewing slightly easier :) |
@bors r+ rollup |
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
Rollup merge of #147101 - yotamofek:pr/iter-eq-and-eq-by, r=jdonszelmann Use `Iterator::eq` and (dogfood) `eq_by` in compiler and library Now that #137122 has landed, we can replace stuff that looks like: ```rust let a: &[T]; let b: &[T]; let eq = a.len() == b.len() && a.iter().zip(b).all(|(a,b)| a == b) ``` with the much simpler `a.iter().eq(b)`, without losing the perf benefit of the different-length-fast-path. Also dogfooded `Iterator::eq_by` (cc #64295 ) while I'm at it. First commit (4d1b6fa) should be very straightforward to review, second one (049a460) is slightly more creative, but IMHO a nice cleanup.
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
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
…jdonszelmann Use `Iterator::eq` and (dogfood) `eq_by` in compiler and library Now that rust-lang#137122 has landed, we can replace stuff that looks like: ```rust let a: &[T]; let b: &[T]; let eq = a.len() == b.len() && a.iter().zip(b).all(|(a,b)| a == b) ``` with the much simpler `a.iter().eq(b)`, without losing the perf benefit of the different-length-fast-path. Also dogfooded `Iterator::eq_by` (cc rust-lang#64295 ) while I'm at it. First commit (4d1b6fa) should be very straightforward to review, second one (049a460) is slightly more creative, but IMHO a nice cleanup.
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
Now that #137122 has landed, we can replace stuff that looks like:
with the much simpler
a.iter().eq(b)
, without losing the perf benefit of the different-length-fast-path.Also dogfooded
Iterator::eq_by
(cc #64295 ) while I'm at it.First commit (4d1b6fa) should be very straightforward to review, second one (049a460) is slightly more creative, but IMHO a nice cleanup.