mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Minor 'node_from_nodes_and_strings' cleanup
This prevents an 'IntoIter' from getting unnecessarily allocated
This commit is contained in:
parent
fe4a5890d1
commit
9443b89af7
1 changed files with 5 additions and 7 deletions
|
@ -931,15 +931,13 @@ impl Document {
|
|||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#converting-nodes-into-a-node
|
||||
pub fn node_from_nodes_and_strings(&self, nodes: Vec<NodeOrString>)
|
||||
pub fn node_from_nodes_and_strings(&self, mut nodes: Vec<NodeOrString>)
|
||||
-> Fallible<Root<Node>> {
|
||||
if nodes.len() == 1 {
|
||||
match nodes.into_iter().next().unwrap() {
|
||||
NodeOrString::eNode(node) => Ok(node),
|
||||
NodeOrString::eString(string) => {
|
||||
Ok(Root::upcast(self.CreateTextNode(string)))
|
||||
},
|
||||
}
|
||||
Ok(match nodes.pop().unwrap() {
|
||||
NodeOrString::eNode(node) => node,
|
||||
NodeOrString::eString(string) => Root::upcast(self.CreateTextNode(string)),
|
||||
})
|
||||
} else {
|
||||
let fragment = Root::upcast::<Node>(self.CreateDocumentFragment());
|
||||
for node in nodes {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue