mirror of
https://github.com/servo/servo.git
synced 2025-08-10 16:05:43 +01:00
script: Use atom comparison in more places, especially for attributes.
75% improvement in style recalc for Guardians of the Galaxy.
This commit is contained in:
parent
d168501555
commit
ee2ccc4f87
31 changed files with 305 additions and 237 deletions
|
@ -48,7 +48,7 @@ impl HTMLLinkElement {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_attr(element: JSRef<Element>, name: &str) -> Option<String> {
|
||||
fn get_attr(element: JSRef<Element>, name: &Atom) -> Option<String> {
|
||||
let elem = element.get_attribute(ns!(""), name).root();
|
||||
elem.map(|e| e.value().as_slice().to_string())
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLLinkElement> {
|
|||
}
|
||||
|
||||
let element: JSRef<Element> = ElementCast::from_ref(*self);
|
||||
let rel = get_attr(element, "rel");
|
||||
let rel = get_attr(element, &atom!("rel"));
|
||||
|
||||
match (rel, name.as_slice()) {
|
||||
(ref rel, "href") => {
|
||||
|
@ -97,8 +97,8 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLLinkElement> {
|
|||
if tree_in_doc {
|
||||
let element: JSRef<Element> = ElementCast::from_ref(*self);
|
||||
|
||||
let rel = get_attr(element, "rel");
|
||||
let href = get_attr(element, "href");
|
||||
let rel = get_attr(element, &atom!("rel"));
|
||||
let href = get_attr(element, &atom!("href"));
|
||||
|
||||
match (rel, href) {
|
||||
(ref rel, Some(ref href)) if is_stylesheet(rel) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue