Skip to content

Commit 1ee5b2a

Browse files
committed
Eliminate redundant CombinationsWithReplacement::k
It is given by indices.len. (Similar to what we do in Combinations.)
1 parent 4114081 commit 1ee5b2a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/combinations_with_replacement.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ where
1212
I: Iterator,
1313
I::Item: Clone,
1414
{
15-
k: usize,
1615
indices: Vec<usize>,
1716
// The current known max index value. This increases as pool grows.
1817
max_index: usize,
@@ -25,7 +24,7 @@ where
2524
I: Iterator + fmt::Debug,
2625
I::Item: fmt::Debug + Clone,
2726
{
28-
debug_fmt_fields!(Combinations, k, indices, max_index, pool, first);
27+
debug_fmt_fields!(Combinations, indices, max_index, pool, first);
2928
}
3029

3130
impl<I> CombinationsWithReplacement<I>
@@ -49,7 +48,6 @@ where
4948
let pool: LazyBuffer<I> = LazyBuffer::new(iter);
5049

5150
CombinationsWithReplacement {
52-
k,
5351
indices,
5452
max_index: 0,
5553
pool,
@@ -67,7 +65,7 @@ where
6765
// If this is the first iteration, return early
6866
if self.first {
6967
// In empty edge cases, stop iterating immediately
70-
return if self.k != 0 && !self.pool.get_next() {
68+
return if self.indices.len() != 0 && !self.pool.get_next() {
7169
None
7270
// Otherwise, yield the initial state
7371
} else {

0 commit comments

Comments
 (0)