aboutsummaryrefslogtreecommitdiffstats
path: root/src/content
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-19 17:56:57 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-07-19 17:56:57 +0200
commit0f20660cb95abd4f407bdafa2c45e01829fa971f (patch)
tree865875c20cee2e74f95e54f52aa73105e90067e7 /src/content
parentae0f12e668cfd37728aad907c813431595e6cc1b (diff)
downloadmarkdown-rs-0f20660cb95abd4f407bdafa2c45e01829fa971f.tar.gz
markdown-rs-0f20660cb95abd4f407bdafa2c45e01829fa971f.tar.bz2
markdown-rs-0f20660cb95abd4f407bdafa2c45e01829fa971f.zip
Refactor to remove cloning in `edit_map`
Diffstat (limited to 'src/content')
-rw-r--r--src/content/document.rs8
1 files changed, 4 insertions, 4 deletions
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::<Vec<_>>());
+ .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::<Vec<_>>();
+ 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::<Vec<_>>();
+ 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<Event> {
add,
);
- map.consume(&mut tokenizer.events)
+ map.consume(tokenizer.events.split_off(0))
}