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:
Patrick Walton 2014-09-12 13:28:37 -07:00
parent d168501555
commit ee2ccc4f87
31 changed files with 305 additions and 237 deletions

View file

@ -226,7 +226,7 @@ impl<'a> FlowConstructor<'a> {
//FIXME: would it make more sense to use HTMLInputElement::input_type instead of the raw
// value? definitely for string comparisons.
let elem = node.as_element();
let data = match elem.get_attr(&ns!(""), "type") {
let data = match elem.get_attr(&ns!(""), &atom!("type")) {
Some("checkbox") | Some("radio") => None,
Some("button") | Some("submit") | Some("reset") =>
Some(node.get_input_value().len() as u32),
@ -1158,7 +1158,7 @@ trait ObjectElement<'a> {
impl<'ln> ObjectElement<'ln> for ThreadSafeLayoutNode<'ln> {
fn get_type_and_data(&self) -> (Option<&'ln str>, Option<&'ln str>) {
let elem = self.as_element();
(elem.get_attr(&ns!(""), "type"), elem.get_attr(&ns!(""), "data"))
(elem.get_attr(&ns!(""), &atom!("type")), elem.get_attr(&ns!(""), &atom!("data")))
}
fn has_object_data(&self) -> bool {