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 61642d64b5
commit 874db26104
32 changed files with 300 additions and 147 deletions

View file

@ -769,16 +769,19 @@ pub trait RawLayoutNodeHelpers {
}
impl RawLayoutNodeHelpers for Node {
#[inline]
unsafe fn get_hover_state_for_layout(&self) -> bool {
(*self.unsafe_get_flags()).contains(InHoverState)
}
#[inline]
unsafe fn get_disabled_state_for_layout(&self) -> bool {
(*self.unsafe_get_flags()).contains(InDisabledState)
}
#[inline]
unsafe fn get_enabled_state_for_layout(&self) -> bool {
(*self.unsafe_get_flags()).contains(InEnabledState)
}
#[inline]
fn type_id_for_layout(&self) -> NodeTypeId {
self.type_id
}
@ -1413,6 +1416,7 @@ impl Node {
}
}
#[inline]
pub unsafe fn unsafe_get_flags(&self) -> *const NodeFlags {
mem::transmute(&self.flags)
}
@ -1987,7 +1991,7 @@ impl<'a> VirtualMethods for JSRef<'a, Node> {
}
}
impl<'a> style::TNode<JSRef<'a, Element>> for JSRef<'a, Node> {
impl<'a> style::TNode<JSRef<'a,Element>> for JSRef<'a,Node> {
fn parent_node(&self) -> Option<JSRef<'a, Node>> {
(self as &NodeHelpers).parent_node().map(|node| *node.root())
}
@ -2021,9 +2025,9 @@ impl<'a> style::TNode<JSRef<'a, Element>> for JSRef<'a, Node> {
fn match_attr(&self, attr: &style::AttrSelector, test: |&str| -> bool) -> bool {
let name = {
if self.is_html_element_in_html_document() {
attr.lower_name.as_slice()
&attr.lower_name
} else {
attr.name.as_slice()
&attr.name
}
};
match attr.namespace {