From 0f20660cb95abd4f407bdafa2c45e01829fa971f Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 19 Jul 2022 17:56:57 +0200 Subject: Refactor to remove cloning in `edit_map` --- src/content/document.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/content') diff --git a/src/content/document.rs b/src/content/document.rs index 63c2476..53e58c4 100644 --- a/src/content/document.rs +++ b/src/content/document.rs @@ -352,7 +352,7 @@ fn containers_after( .last_mut() .unwrap() .0 - .append(&mut tokenizer.events.drain(info.index..).collect::>()); + .append(&mut tokenizer.events.split_off(info.index)); tokenizer.lazy = info.continued != info.stack.len(); tokenizer.interrupt = info.interrupt_before; @@ -433,12 +433,12 @@ fn exit_containers( mut info: DocumentInfo, phase: &Phase, ) -> DocumentInfo { - let mut stack_close = info.stack.drain(info.continued..).collect::>(); + let mut stack_close = info.stack.split_off(info.continued); // So, we’re at the end of a line, but we need to close the *previous* line. if *phase != Phase::Eof { tokenizer.define_skip_current(); - let mut current_events = tokenizer.events.drain(info.index..).collect::>(); + let mut current_events = tokenizer.events.split_off(info.index); let next = info.next; info.next = Box::new(flow); // This is weird but Rust needs a function there. let result = tokenizer.flush(next); @@ -537,5 +537,5 @@ fn resolve(tokenizer: &mut Tokenizer, info: &DocumentInfo) -> Vec { add, ); - map.consume(&mut tokenizer.events) + map.consume(tokenizer.events.split_off(0)) } -- cgit