aboutsummaryrefslogtreecommitdiffstats
path: root/src/construct/list.rs
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/construct/list.rs
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/construct/list.rs')
-rw-r--r--src/construct/list.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/construct/list.rs b/src/construct/list.rs
index 9cd3b62..db8af36 100644
--- a/src/construct/list.rs
+++ b/src/construct/list.rs
@@ -432,8 +432,7 @@ pub fn resolve_list_item(tokenizer: &mut Tokenizer) -> Vec<Event> {
if previous.0 == current.0 && previous.1 == current.1 && before == current.2 {
let previous_mut = &mut lists_wip[list_index];
previous_mut.3 = current.3;
- let mut remainder = lists_wip.drain((list_index + 1)..).collect::<Vec<_>>();
- lists.append(&mut remainder);
+ lists.append(&mut lists_wip.split_off(list_index + 1));
matched = true;
break;
}
@@ -457,8 +456,7 @@ pub fn resolve_list_item(tokenizer: &mut Tokenizer) -> Vec<Event> {
}
if let Some(exit) = exit {
- let mut remainder = lists_wip.drain(exit..).collect::<Vec<_>>();
- lists.append(&mut remainder);
+ lists.append(&mut lists_wip.split_off(exit));
}
lists_wip.push(current);
@@ -494,5 +492,5 @@ pub fn resolve_list_item(tokenizer: &mut Tokenizer) -> Vec<Event> {
index += 1;
}
- edit_map.consume(&mut tokenizer.events)
+ edit_map.consume(tokenizer.events.split_off(0))
}