mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 05:15:00 +00:00
Optimize Rope::append
by merging chunks only when they're underflowing
This commit is contained in:
parent
76a74e431e
commit
c9987f9488
1 changed files with 6 additions and 2 deletions
|
@ -26,8 +26,12 @@ impl Rope {
|
|||
let mut chunks = rope.chunks.cursor::<(), ()>();
|
||||
chunks.next();
|
||||
if let Some(chunk) = chunks.item() {
|
||||
self.push(&chunk.0);
|
||||
chunks.next();
|
||||
if self.chunks.last().map_or(false, |c| c.0.len() < CHUNK_BASE)
|
||||
|| chunk.0.len() < CHUNK_BASE
|
||||
{
|
||||
self.push(&chunk.0);
|
||||
chunks.next();
|
||||
}
|
||||
}
|
||||
|
||||
self.chunks.push_tree(chunks.suffix(&()), &());
|
||||
|
|
Loading…
Reference in a new issue