Skip to content

Commit

Permalink
Drain instead of clearing vec
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivordir committed Mar 21, 2024
1 parent a533a8e commit 3cf7968
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/kmeans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,9 @@ where
for _ in 0..(samples / BATCH) {
batch.extend((0..BATCH).map(|_| colors[distribution.sample(rng)]));

for &color in &batch {
for color in batch.drain(..) {
self.add_sample(color);
}

batch.clear();
}

batch.extend((0..(samples % BATCH)).map(|_| colors[distribution.sample(rng)]));
Expand Down

0 comments on commit 3cf7968

Please sign in to comment.