hash ptr rather than value of extended selector
this change *doubles* speed of the `huge.scss` benchmark. it may not be wholly sound, though. I haven't come across a test case that can make this fail, but that's not to say one doesn't exist.
This commit is contained in:
parent
c66ecdd57d
commit
f6f4d8ab1b
@ -2,6 +2,7 @@ use std::{
|
|||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
collections::{hash_set::IntoIter, HashSet},
|
collections::{hash_set::IntoIter, HashSet},
|
||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
|
ptr,
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -19,8 +20,14 @@ impl PartialEq for ExtendedSelector {
|
|||||||
impl Eq for ExtendedSelector {}
|
impl Eq for ExtendedSelector {}
|
||||||
|
|
||||||
impl Hash for ExtendedSelector {
|
impl Hash for ExtendedSelector {
|
||||||
|
// We hash the ptr here for efficiency.
|
||||||
|
// TODO: is this an issue? it probably is,
|
||||||
|
// but I haven't managed to find a test case
|
||||||
|
// that exhibits it.
|
||||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||||
self.0.borrow().hash(state);
|
ptr::hash(&*self.0, state)
|
||||||
|
// in case we need to hash the actual value:
|
||||||
|
// self.0.borrow().hash(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user