Optimise Chars::last() #37882

Merged
merged 2 commits into from Nov 20, 2016

Projects

None yet

7 participants

@ollie27
Contributor
ollie27 commented Nov 19, 2016

The default implementation of last() goes through the entire iterator
but that's not needed here.

@ollie27 ollie27 Optimise Chars::last()
The default implementation of last() goes through the entire iterator
but that's not needed here.
de2f617
@rust-highfive
Collaborator

r? @aturon

(rust_highfive has picked a reviewer for you, use r? to override)

@bluss
Contributor
bluss commented Nov 19, 2016

@bors r+ rollup

Thank you!

@bors
Contributor
bors commented Nov 19, 2016

📌 Commit de2f617 has been approved by bluss

@bluss
Contributor
bluss commented Nov 19, 2016

By the way, this applies to char_indices as well. Another commit or another PR is welcome.

@ollie27 ollie27 Optimise CharIndices::last()
The default implementation of last() goes through the entire iterator
but that's not needed here.
9e86e18
@ollie27
Contributor
ollie27 commented Nov 20, 2016

Good point. I've applied the same to CharIndices.

@bluss
Contributor
bluss commented Nov 20, 2016

@bors r+ rollup

@bors
Contributor
bors commented Nov 20, 2016

📌 Commit 9e86e18 has been approved by bluss

@GuillaumeGomez GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Nov 20, 2016
@GuillaumeGomez GuillaumeGomez Rollup merge of #37882 - ollie27:chars_last, r=bluss
Optimise Chars::last()

The default implementation of last() goes through the entire iterator
but that's not needed here.
b0354fe
@bors bors added a commit that referenced this pull request Nov 20, 2016
@bors bors Auto merge of #37896 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 8 pull requests

- Successful merges: #37835, #37840, #37841, #37848, #37876, #37880, #37881, #37882
- Failed merges:
fb12219
@bors bors merged commit 9e86e18 into rust-lang:master Nov 20, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@ollie27 ollie27 deleted the ollie27:chars_last branch Nov 20, 2016
@brson brson added the relnotes label Nov 22, 2016
@durka
Contributor
durka commented Nov 25, 2016

Shouldn't this apply to any DoubleEndedIterator?

@ollie27
Contributor
ollie27 commented Nov 25, 2016

Yeah, but I think it might be breaking change to do this for iterators that might have side effects.

@bluss
Contributor
bluss commented Nov 25, 2016

Yes. Iterator::last's doc is specific about how it goes about finding the last value (traversing it all).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment