Store slow selector flags in a hashmap.

This reduces the flag setting overhead on a pessimal testcase from over a
second to ~20ms.
This commit is contained in:
Bobby Holley 2017-04-13 15:42:51 +08:00
parent a32596131a
commit 297dc33a9f
5 changed files with 112 additions and 42 deletions

View file

@ -55,6 +55,7 @@ use servo_atoms::Atom;
use servo_url::ServoUrl;
use std::fmt;
use std::fmt::Debug;
use std::hash::{Hash, Hasher};
use std::marker::PhantomData;
use std::mem::transmute;
use std::sync::Arc;
@ -475,6 +476,14 @@ impl<'le> PartialEq for ServoLayoutElement<'le> {
}
}
impl<'le> Hash for ServoLayoutElement<'le> {
fn hash<H: Hasher>(&self, state: &mut H) {
self.element.hash(state);
}
}
impl<'le> Eq for ServoLayoutElement<'le> {}
impl<'le> ServoLayoutElement<'le> {
fn from_layout_js(el: LayoutJS<Element>) -> ServoLayoutElement<'le> {
ServoLayoutElement {