Input.insert: No need to clone

This commit is contained in:
Peter Kolloch 2021-05-13 13:29:01 +02:00
parent 73cf47a533
commit e89f1e6c4d

View file

@ -67,13 +67,11 @@ impl Input {
/// Insert some items to the Input items just after current parsing cursor.
/// Usually used by replaced items recovering.
pub(crate) fn insert(&mut self, insert_items: &[&str]) {
self.items = {
let mut new_items: Vec<OsString> = insert_items.iter().map(OsString::from).collect();
for unparsed_item in &self.items[self.cursor..] {
new_items.push(unparsed_item.clone());
}
new_items
};
self.items = insert_items
.iter()
.map(OsString::from)
.chain(self.items.drain(self.cursor..))
.collect();
self.cursor = 0;
}
}