Skip to content

Commit c71766d

Browse files
committed
Improve the performance of snapshot_vec::extend
1 parent 3c5e8b4 commit c71766d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/snapshot_vec.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,12 @@ impl<D: SnapshotVecDelegate> Extend<D::Value> for SnapshotVec<D> {
275275
where
276276
T: IntoIterator<Item = D::Value>,
277277
{
278-
for item in iterable {
279-
self.push(item);
278+
let initial_len = self.values.len();
279+
self.values.extend(iterable);
280+
let final_len = self.values.len();
281+
282+
if self.in_snapshot() {
283+
self.undo_log.extend((initial_len..final_len).map(|len| NewElem(len)));
280284
}
281285
}
282286
}

0 commit comments

Comments
 (0)