diff --git a/crates/loro-internal/src/delta/seq.rs b/crates/loro-internal/src/delta/seq.rs index 70469f4b..78744bd1 100644 --- a/crates/loro-internal/src/delta/seq.rs +++ b/crates/loro-internal/src/delta/seq.rs @@ -440,7 +440,9 @@ impl DeltaValue for Vec { } fn take(&mut self, length: usize) -> Self { - self.drain(0..length).collect() + let mut new = self.split_off(length); + std::mem::swap(self, &mut new); + new } } @@ -450,7 +452,9 @@ impl DeltaValue for String { } fn take(&mut self, length: usize) -> Self { - self.drain(0..length).collect() + let mut new = self.split_off(length); + std::mem::swap(self, &mut new); + new } }