mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 21:42:59 -05:00
Type Tools: reserve only the old run count in Make Numbers Sequence
replace_runs reserved old.len() + 2 * changes.len() runs. For 2,000 numbers that is 4,001 runs on every preview change, while push merges neighbors with equal style and the output usually keeps about old.len() runs. The vector now starts at old.len() and grows when formatting splits a run. This changes only the initial allocation, so no test can fail without it; the existing long-text and styled-output tests still pass.
This commit is contained in:
1 parent
a0b0702a05
commit
bd1f5daf2a
1 file changed
+1
-1
@@ -336,7 +336,7 @@ pub(crate) fn apply(t: &mut TextObject, changes: &[Edit]) {
|
||||
fn replace_runs(runs: &mut Vec<TextRun>, changes: &[Edit]) {
|
||||
note_text_pass();
|
||||
let old = std::mem::take(runs);
|
||||
let mut out: Vec<TextRun> = Vec::with_capacity(old.len() + 2 * changes.len());
|
||||
let mut out: Vec<TextRun> = Vec::with_capacity(old.len());
|
||||
let mut pending = changes.iter().rev().peekable();
|
||||
// Where the run starts and where the last replaced range ends.
|
||||
let (mut off, mut cut) = (0, 0);
|
||||
|
||||
Reference in new issue
Block a user