diff options
| author | Josh Stone <jistone@redhat.com> | 2020-04-07 16:50:16 -0700 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2020-04-07 16:50:16 -0700 |
| commit | 8aac1077ed495ef8d1241ce76d4b64d7eb13a856 (patch) | |
| tree | c58c2a1675c5e5445b1976ffd3436eb5723e4a3a /src/libcore | |
| parent | 859b8da21fc82c08fde8b3aafefc12881a0c3f09 (diff) | |
| download | rust-8aac1077ed495ef8d1241ce76d4b64d7eb13a856.tar.gz rust-8aac1077ed495ef8d1241ce76d4b64d7eb13a856.zip | |
Reduce callsites in Chain::count()
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/iter/adapters/chain.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/libcore/iter/adapters/chain.rs b/src/libcore/iter/adapters/chain.rs index 6c97c43df40..0100e62fae6 100644 --- a/src/libcore/iter/adapters/chain.rs +++ b/src/libcore/iter/adapters/chain.rs @@ -62,12 +62,15 @@ where #[inline] #[rustc_inherit_overflow_checks] fn count(self) -> usize { - match self { - Chain { a: Some(a), b: Some(b) } => a.count() + b.count(), - Chain { a: Some(a), b: None } => a.count(), - Chain { a: None, b: Some(b) } => b.count(), - Chain { a: None, b: None } => 0, - } + let a_count = match self.a { + Some(a) => a.count(), + None => 0, + }; + let b_count = match self.b { + Some(b) => b.count(), + None => 0, + }; + a_count + b_count } fn try_fold<Acc, F, R>(&mut self, mut acc: Acc, mut f: F) -> R |
