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

@ -20,6 +20,7 @@ use shared_lock::Locked;
use sink::Push;
use std::fmt;
use std::fmt::Debug;
use std::hash::Hash;
use std::ops::Deref;
use std::sync::Arc;
use stylist::ApplicableDeclarationBlock;
@ -275,7 +276,8 @@ pub struct AnimationRules(pub Option<Arc<Locked<PropertyDeclarationBlock>>>,
pub Option<Arc<Locked<PropertyDeclarationBlock>>>);
/// The element trait, the main abstraction the style crate acts over.
pub trait TElement : PartialEq + Debug + Sized + Copy + Clone + ElementExt + PresentationalHintsSynthetizer {
pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone +
ElementExt + PresentationalHintsSynthetizer {
/// The concrete node type.
type ConcreteNode: TNode<ConcreteElement = Self>;
@ -518,7 +520,7 @@ impl<N: TNode> Deref for SendNode<N> {
/// Same reason as for the existence of SendNode, SendElement does the proper
/// things for a given `TElement`.
#[derive(Debug, PartialEq)]
#[derive(Debug, Eq, Hash, PartialEq)]
pub struct SendElement<E: TElement>(E);
unsafe impl<E: TElement> Send for SendElement<E> {}
impl<E: TElement> SendElement<E> {