Skip to content

Commit

Permalink
Use HashMap::find_with_or_insert_with in DocumentHelpers::register_na…
Browse files Browse the repository at this point in the history
…med_element (fixes #3193)
  • Loading branch information
ttaubert committed Oct 6, 2014
1 parent d23e45f commit a338fbc
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions components/script/dom/document.rs
Expand Up @@ -242,11 +242,9 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {

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();
match idmap.find_mut(&id) {
Some(elements) => {
idmap.find_with_or_insert_with(id, element,
|_key, elements, element| {
let new_node: JSRef<Node> = NodeCast::from_ref(element);
let mut head : uint = 0u;
let root: JSRef<Node> = NodeCast::from_ref(*root);
Expand All @@ -265,13 +263,9 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
}
}
elements.insert_unrooted(head, &element);
return;
},
None => (),
}
let mut elements = vec!();
elements.push_unrooted(&element);
idmap.insert(id, elements);
|_key, element| vec![element.unrooted()]
);
}

fn load_anchor_href(self, href: DOMString) {
Expand Down

5 comments on commit a338fbc

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging ttaubert/servo/issue/3193-named-element-mangle = a338fbc into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ttaubert/servo/issue/3193-named-element-mangle = a338fbc merged ok, testing candidate = a127fcd

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = a127fcd

Please sign in to comment.