-
Notifications
You must be signed in to change notification settings - Fork 13k
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
core::iter: Refactor iterators #16225
Conversation
@@ -720,21 +715,10 @@ pub trait ExactSize<A> : DoubleEndedIterator<A> { | |||
/// If no element matches, None is returned. | |||
#[inline] | |||
fn rposition(&mut self, predicate: |A| -> bool) -> Option<uint> { | |||
let (lower, upper) = self.size_hint(); | |||
assert!(upper == Some(lower)); |
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 guessing the removal of this is why you're reporting better numbers on the benchmark.
Right now clients of ExactSize
typically include this test. I don't think all clients should be including the test, instead len()
should do any assertions necessary, but I'm not sure if sneaking that into this PR is appropriate (especially since you're only updating one client and not all).
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.
Doesn't len()
(as defined just below) already include this same assertion, though?
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 it already does the assertions? Then why is everyone using size_hint()
and asserting manually?
r=me with the one change. |
Simplifying the code of methods: nth, fold, rposition and iterators: Filter, FilterMap, SkipWhile Adding basic benchmarks
@kballard Pushed the change. |
Simplifying the code of methods: `nth`, `fold`, `rposition`, and iterators: `Filter`, `FilterMap`, `SkipWhile`. ``` before test iter::bench_multiple_take ... bench: 15 ns/iter (+/- 0) test iter::bench_rposition ... bench: 349 ns/iter (+/- 94) test iter::bench_skip_while ... bench: 158 ns/iter (+/- 6) after test iter::bench_multiple_take ... bench: 15 ns/iter (+/- 0) test iter::bench_rposition ... bench: 314 ns/iter (+/- 2) test iter::bench_skip_while ... bench: 107 ns/iter (+/- 0) ``` @koalazen has the code for `Skip`. Once #16011 is fixed, `min_max` could use a for loop.
minor: Render more crate information in status command
Simplifying the code of methods:
nth
,fold
,rposition
, and iterators:Filter
,FilterMap
,SkipWhile
.@koalazen has the code for
Skip
.Once #16011 is fixed,
min_max
could use a for loop.