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
|
// 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>> {
|
-> Fallible<Root<Node>> {
|
||||||
if nodes.len() == 1 {
|
if nodes.len() == 1 {
|
||||||
match nodes.into_iter().next().unwrap() {
|
Ok(match nodes.pop().unwrap() {
|
||||||
NodeOrString::eNode(node) => Ok(node),
|
NodeOrString::eNode(node) => node,
|
||||||
NodeOrString::eString(string) => {
|
NodeOrString::eString(string) => Root::upcast(self.CreateTextNode(string)),
|
||||||
Ok(Root::upcast(self.CreateTextNode(string)))
|
})
|
||||||
},
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
let fragment = Root::upcast::<Node>(self.CreateDocumentFragment());
|
let fragment = Root::upcast::<Node>(self.CreateDocumentFragment());
|
||||||
for node in nodes {
|
for node in nodes {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue