diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-03-21 19:38:16 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-04-08 02:02:11 +0200 |
commit | e29b84de18ab1a3e7044d63a0b83a4727e5622d4 (patch) | |
tree | 3c15d02f4a6e8f7f2aa5eab0094201f8e600e4c9 /components/style/gecko_string_cache | |
parent | 65ebbb7c561a8b457476d5aff3ebbcb6c7adf751 (diff) | |
download | servo-e29b84de18ab1a3e7044d63a0b83a4727e5622d4.tar.gz servo-e29b84de18ab1a3e7044d63a0b83a4727e5622d4.zip |
style: Hash less stuff in the bloom filter, using the precomputed hashes we have.
Diffstat (limited to 'components/style/gecko_string_cache')
-rw-r--r-- | components/style/gecko_string_cache/mod.rs | 8 | ||||
-rw-r--r-- | components/style/gecko_string_cache/namespace.rs | 18 |
2 files changed, 26 insertions, 0 deletions
diff --git a/components/style/gecko_string_cache/mod.rs b/components/style/gecko_string_cache/mod.rs index b6659c6ab91..b10fd58174a 100644 --- a/components/style/gecko_string_cache/mod.rs +++ b/components/style/gecko_string_cache/mod.rs @@ -10,6 +10,7 @@ use gecko_bindings::bindings::Gecko_AddRefAtom; use gecko_bindings::bindings::Gecko_Atomize; use gecko_bindings::bindings::Gecko_ReleaseAtom; use gecko_bindings::structs::nsIAtom; +use precomputed_hash::PrecomputedHash; use std::borrow::{Cow, Borrow}; use std::char::{self, DecodeUtf16}; use std::fmt::{self, Write}; @@ -56,6 +57,13 @@ impl Deref for Atom { } } +impl PrecomputedHash for Atom { + #[inline] + fn precomputed_hash(&self) -> u32 { + self.get_hash() + } +} + impl Borrow<WeakAtom> for Atom { #[inline] fn borrow(&self) -> &WeakAtom { diff --git a/components/style/gecko_string_cache/namespace.rs b/components/style/gecko_string_cache/namespace.rs index 117f1923151..9368c16286f 100644 --- a/components/style/gecko_string_cache/namespace.rs +++ b/components/style/gecko_string_cache/namespace.rs @@ -5,6 +5,7 @@ //! A type to represent a namespace. use gecko_bindings::structs::nsIAtom; +use precomputed_hash::PrecomputedHash; use std::borrow::{Borrow, Cow}; use std::fmt; use std::ops::Deref; @@ -19,10 +20,27 @@ macro_rules! ns { #[derive(Debug, PartialEq, Eq, Clone, Default, Hash)] pub struct Namespace(pub Atom); +impl PrecomputedHash for Namespace { + #[inline] + fn precomputed_hash(&self) -> u32 { + self.0.precomputed_hash() + } +} + /// A Gecko WeakNamespace is a wrapped WeakAtom. #[derive(Hash)] pub struct WeakNamespace(WeakAtom); +impl Deref for WeakNamespace { + type Target = WeakAtom; + + #[inline] + fn deref(&self) -> &WeakAtom { + &self.0 + } +} + + impl Deref for Namespace { type Target = WeakNamespace; |