diff options
author | Bobby Holley <bobbyholley@gmail.com> | 2017-04-13 15:42:51 +0800 |
---|---|---|
committer | Bobby Holley <bobbyholley@gmail.com> | 2017-04-13 21:52:47 +0800 |
commit | 297dc33a9f24963010b5803c06b331e012386a4d (patch) | |
tree | 7f527675b023c39aa7dc21c9324d0aa3b1056b7d /components/script/layout_wrapper.rs | |
parent | a32596131ac729ee5de241b3190242b1a1862e0b (diff) | |
download | servo-297dc33a9f24963010b5803c06b331e012386a4d.tar.gz servo-297dc33a9f24963010b5803c06b331e012386a4d.zip |
Store slow selector flags in a hashmap.
This reduces the flag setting overhead on a pessimal testcase from over a
second to ~20ms.
Diffstat (limited to 'components/script/layout_wrapper.rs')
-rw-r--r-- | components/script/layout_wrapper.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs index 4b118bdf7f1..e4df1b77ec3 100644 --- a/components/script/layout_wrapper.rs +++ b/components/script/layout_wrapper.rs @@ -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 { |