style: Hash less stuff in the bloom filter, using the precomputed hashes we have.

This commit is contained in:
Emilio Cobos Álvarez 2017-03-21 19:38:16 +01:00
parent 65ebbb7c56
commit e29b84de18
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
10 changed files with 129 additions and 63 deletions

View file

@ -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;