diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2014-09-12 13:28:37 -0700 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2014-10-14 10:32:40 -0700 |
commit | ee2ccc4f872ba33a86057d87a99d1015b3c41cf1 (patch) | |
tree | 3a7ef263aa401fb3a36e9d48ff5bc8a384ab1f65 /components/script/dom/document.rs | |
parent | d1685015559562a42cc440f4e3b7a97d38cc642c (diff) | |
download | servo-ee2ccc4f872ba33a86057d87a99d1015b3c41cf1.tar.gz servo-ee2ccc4f872ba33a86057d87a99d1015b3c41cf1.zip |
script: Use atom comparison in more places, especially for attributes.
75% improvement in style recalc for Guardians of the Galaxy.
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r-- | components/script/dom/document.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index f37a8feb2f6..bbcf3514734 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -123,7 +123,8 @@ impl CollectionFilter for EmbedsFilter { struct LinksFilter; impl CollectionFilter for LinksFilter { fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool { - (elem.is_htmlanchorelement() || elem.is_htmlareaelement()) && elem.has_attribute("href") + (elem.is_htmlanchorelement() || elem.is_htmlareaelement()) && + elem.has_attribute(&atom!("href")) } } @@ -147,7 +148,7 @@ impl CollectionFilter for ScriptsFilter { struct AnchorsFilter; impl CollectionFilter for AnchorsFilter { fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool { - elem.is_htmlanchorelement() && elem.has_attribute("href") + elem.is_htmlanchorelement() && elem.has_attribute(&atom!("href")) } } @@ -278,7 +279,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> { self.GetElementById(fragid.clone()).or_else(|| { let check_anchor = |&node: &JSRef<HTMLAnchorElement>| { let elem: JSRef<Element> = ElementCast::from_ref(node); - elem.get_attribute(ns!(""), "name").root().map_or(false, |attr| { + elem.get_attribute(ns!(""), &atom!("name")).root().map_or(false, |attr| { attr.value().as_slice() == fragid.as_slice() }) }; @@ -785,7 +786,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { } let element: JSRef<Element> = ElementCast::to_ref(node).unwrap(); - element.get_attribute(ns!(""), "name").root().map_or(false, |attr| { + element.get_attribute(ns!(""), &atom!("name")).root().map_or(false, |attr| { attr.value().as_slice() == name.as_slice() }) }) |