Skip to content

Commit c92f6a5

Browse files
committed
Avoid redundant bookkeeping in pool_len
lazy_buffer gives `len` in via a field lookup (Vec::len), so I do not see why we should duplicate this compuation manually.
1 parent e7ebc13 commit c92f6a5

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/combinations.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ impl<I> Iterator for Combinations<I>
5151
{
5252
type Item = Vec<I::Item>;
5353
fn next(&mut self) -> Option<Self::Item> {
54-
let mut pool_len = self.pool.len();
55-
5654
if self.first {
5755
if self.pool.is_done() {
5856
return None;
@@ -65,13 +63,11 @@ impl<I> Iterator for Combinations<I>
6563
let mut i: usize = self.indices.len() - 1;
6664

6765
// Check if we need to consume more from the iterator
68-
if self.indices[i] == pool_len - 1 && !self.pool.is_done() {
69-
if self.pool.get_next() {
70-
pool_len += 1;
71-
}
66+
if self.indices[i] == self.pool.len() - 1 && !self.pool.is_done() {
67+
self.pool.get_next(); // may change pool size
7268
}
7369

74-
while self.indices[i] == i + pool_len - self.indices.len() {
70+
while self.indices[i] == i + self.pool.len() - self.indices.len() {
7571
if i > 0 {
7672
i -= 1;
7773
} else {

0 commit comments

Comments
 (0)