diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-09-13 16:51:31 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-13 16:51:31 +0530 |
| commit | d5b86d5ee912407aef6af3a152a94bde70bacb7a (patch) | |
| tree | 9effa6a3c60a5ab146fd1d50d0e7e6cb1b01f7b0 /compiler/rustc_session | |
| parent | db75d7e14b6c5157e12fea4a1158e9dd58e92c36 (diff) | |
| parent | 66211d83f9ad82770f2f81d37aae1544365a9a32 (diff) | |
| download | rust-d5b86d5ee912407aef6af3a152a94bde70bacb7a.tar.gz rust-d5b86d5ee912407aef6af3a152a94bde70bacb7a.zip | |
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.
Diffstat (limited to 'compiler/rustc_session')
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index caf9d582ab0..9ed4faccdb8 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -1309,10 +1309,8 @@ pub fn build_session( let warnings_allow = sopts .lint_opts .iter() - .filter(|&&(ref key, _)| *key == "warnings") - .map(|&(_, ref level)| *level == lint::Allow) - .last() - .unwrap_or(false); + .rfind(|&&(ref key, _)| *key == "warnings") + .map_or(false, |&(_, level)| level == lint::Allow); let cap_lints_allow = sopts.lint_cap.map_or(false, |cap| cap == lint::Allow); let can_emit_warnings = !(warnings_allow || cap_lints_allow); |
