aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/attr.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-09-12 13:28:37 -0700
committerPatrick Walton <pcwalton@mimiga.net>2014-09-17 13:17:12 -0700
commit874db261046d6155b1942efa106d2e0014295d6d (patch)
treedd766824192dd26a929bd0b2ce0f5e3d9d0b7677 /components/script/dom/attr.rs
parent61642d64b5c06f30fd68961e5ffd21a35dacbc4c (diff)
downloadservo-874db261046d6155b1942efa106d2e0014295d6d.tar.gz
servo-874db261046d6155b1942efa106d2e0014295d6d.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/attr.rs')
-rw-r--r--components/script/dom/attr.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs
index be419eb2a61..60b414199e5 100644
--- a/components/script/dom/attr.rs
+++ b/components/script/dom/attr.rs
@@ -13,13 +13,13 @@ use dom::element::{Element, AttributeHandlers};
use dom::node::Node;
use dom::window::Window;
use dom::virtualmethods::vtable_for;
+
use servo_util::atom::Atom;
use servo_util::namespace;
use servo_util::namespace::Namespace;
use servo_util::str::{DOMString, split_html_space_chars};
use std::cell::{Ref, RefCell};
use std::mem;
-use std::slice::Items;
pub enum AttrSettingType {
FirstSetAttr,
@@ -51,9 +51,9 @@ impl AttrValue {
AtomAttrValue(value)
}
- pub fn tokens<'a>(&'a self) -> Option<Items<'a, Atom>> {
+ pub fn tokens<'a>(&'a self) -> Option<&'a [Atom]> {
match *self {
- TokenListAttrValue(_, ref tokens) => Some(tokens.iter()),
+ TokenListAttrValue(_, ref tokens) => Some(tokens.as_slice()),
_ => None
}
}
@@ -189,17 +189,19 @@ impl<'a> AttrHelpers for JSRef<'a, Attr> {
pub trait AttrHelpersForLayout {
unsafe fn value_ref_forever(&self) -> &'static str;
unsafe fn value_atom_forever(&self) -> Option<Atom>;
- unsafe fn value_tokens_forever(&self) -> Option<Items<Atom>>;
+ unsafe fn value_tokens_forever(&self) -> Option<&'static [Atom]>;
unsafe fn local_name_atom_forever(&self) -> Atom;
}
impl AttrHelpersForLayout for Attr {
+ #[inline]
unsafe fn value_ref_forever(&self) -> &'static str {
// cast to point to T in RefCell<T> directly
let value = mem::transmute::<&RefCell<AttrValue>, &AttrValue>(self.value.deref());
value.as_slice()
}
+ #[inline]
unsafe fn value_atom_forever(&self) -> Option<Atom> {
// cast to point to T in RefCell<T> directly
let value = mem::transmute::<&RefCell<AttrValue>, &AttrValue>(self.value.deref());
@@ -209,15 +211,17 @@ impl AttrHelpersForLayout for Attr {
}
}
- unsafe fn value_tokens_forever(&self) -> Option<Items<Atom>> {
+ #[inline]
+ unsafe fn value_tokens_forever(&self) -> Option<&'static [Atom]> {
// cast to point to T in RefCell<T> directly
let value = mem::transmute::<&RefCell<AttrValue>, &AttrValue>(self.value.deref());
match *value {
- TokenListAttrValue(_, ref tokens) => Some(tokens.iter()),
+ TokenListAttrValue(_, ref tokens) => Some(tokens.as_slice()),
_ => None,
}
}
+ #[inline]
unsafe fn local_name_atom_forever(&self) -> Atom {
self.local_name.clone()
}