mirror of
https://github.com/servo/servo.git
synced 2025-06-15 20:04:28 +00:00
Use Gecko's simpler Bloom filter instead of one based on hash
stretching. This preserves the usage of the Bloom filter throughout style recalc, but the implementation is rewritten. Provides a 15% improvement on Guardians of the Galaxy.
This commit is contained in:
parent
878ece58da
commit
2a790d06dd
10 changed files with 335 additions and 357 deletions
|
@ -38,6 +38,7 @@ use std::ascii::StrAsciiExt;
|
|||
use std::cell::RefCell;
|
||||
use std::default::Default;
|
||||
use std::mem;
|
||||
use std::slice::Items;
|
||||
use string_cache::{Atom, Namespace};
|
||||
use url::UrlParser;
|
||||
|
||||
|
@ -172,6 +173,7 @@ pub trait RawLayoutElementHelpers {
|
|||
unsafe fn get_attr_vals_for_layout<'a>(&'a self, name: &str) -> Vec<&'a str>;
|
||||
unsafe fn get_attr_atom_for_layout(&self, namespace: &Namespace, name: &str) -> Option<Atom>;
|
||||
unsafe fn has_class_for_layout(&self, name: &str) -> bool;
|
||||
unsafe fn get_classes_for_layout<'a>(&'a self) -> Option<Items<'a,Atom>>;
|
||||
}
|
||||
|
||||
impl RawLayoutElementHelpers for Element {
|
||||
|
@ -234,6 +236,19 @@ impl RawLayoutElementHelpers for Element {
|
|||
(*attr).value_tokens_forever().map(|mut tokens| { tokens.any(|atom| atom.as_slice() == name) })
|
||||
}.take().unwrap())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unrooted_must_root)]
|
||||
unsafe fn get_classes_for_layout<'a>(&'a self) -> Option<Items<'a,Atom>> {
|
||||
let attrs: *const Vec<JS<Attr>> = mem::transmute(&self.attrs);
|
||||
(*attrs).iter().find(|attr: & &JS<Attr>| {
|
||||
let attr = attr.unsafe_get();
|
||||
(*attr).local_name_atom_forever().as_slice() == "class"
|
||||
}).and_then(|attr| {
|
||||
let attr = attr.unsafe_get();
|
||||
(*attr).value_tokens_forever()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub trait LayoutElementHelpers {
|
||||
|
@ -1052,4 +1067,19 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> {
|
|||
|
||||
has_class(self, name)
|
||||
}
|
||||
fn each_class(self, callback: |&Atom|) {
|
||||
match self.get_attribute(ns!(""), "class").root() {
|
||||
None => {}
|
||||
Some(attr) => {
|
||||
match attr.deref().value().tokens() {
|
||||
None => {}
|
||||
Some(mut tokens) => {
|
||||
for token in tokens {
|
||||
callback(token)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue