mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Use HashMap::find_with_or_insert_with in DocumentHelpers::register_named_element (fixes #3193)
This commit is contained in:
parent
d23e45fe5d
commit
a338fbc4b5
1 changed files with 4 additions and 10 deletions
|
@ -242,11 +242,9 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
||||||
|
|
||||||
let mut idmap = self.idmap.deref().borrow_mut();
|
let mut idmap = self.idmap.deref().borrow_mut();
|
||||||
|
|
||||||
// FIXME https://github.com/mozilla/rust/issues/13195
|
|
||||||
// Use mangle() when it exists again.
|
|
||||||
let root = self.GetDocumentElement().expect("The element is in the document, so there must be a document element.").root();
|
let root = self.GetDocumentElement().expect("The element is in the document, so there must be a document element.").root();
|
||||||
match idmap.find_mut(&id) {
|
idmap.find_with_or_insert_with(id, element,
|
||||||
Some(elements) => {
|
|_key, elements, element| {
|
||||||
let new_node: JSRef<Node> = NodeCast::from_ref(element);
|
let new_node: JSRef<Node> = NodeCast::from_ref(element);
|
||||||
let mut head : uint = 0u;
|
let mut head : uint = 0u;
|
||||||
let root: JSRef<Node> = NodeCast::from_ref(*root);
|
let root: JSRef<Node> = NodeCast::from_ref(*root);
|
||||||
|
@ -265,13 +263,9 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elements.insert_unrooted(head, &element);
|
elements.insert_unrooted(head, &element);
|
||||||
return;
|
|
||||||
},
|
},
|
||||||
None => (),
|
|_key, element| vec![element.unrooted()]
|
||||||
}
|
);
|
||||||
let mut elements = vec!();
|
|
||||||
elements.push_unrooted(&element);
|
|
||||||
idmap.insert(id, elements);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_anchor_href(self, href: DOMString) {
|
fn load_anchor_href(self, href: DOMString) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue