Rollup merge of #101690 - kadiwa4:avoid_iterator_last, r=oli-obk
Avoid `Iterator::last` Adapters like `Filter` and `Map` use the default implementation of `Iterator::last` which is not short-circuiting (and so does `core::str::Split`). The predicate function will be run for every single item of the underlying iterator. I hope that removing those calls to `last` results in slight performance improvements.
This commit is contained in:
commit
d5b86d5ee9
7 changed files with 11 additions and 15 deletions
|
@ -576,8 +576,7 @@ impl<'hir> Generics<'hir> {
|
|||
if self.has_where_clause_predicates {
|
||||
self.predicates
|
||||
.iter()
|
||||
.filter(|p| p.in_where_clause())
|
||||
.last()
|
||||
.rfind(|&p| p.in_where_clause())
|
||||
.map_or(end, |p| p.span())
|
||||
.shrink_to_hi()
|
||||
.to(end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue