Hoist bloom filter into scoped TLS and simplify code.

This commit is contained in:
Bobby Holley 2016-12-21 11:41:58 -08:00
parent 25f32c4513
commit b6e948dc5d
7 changed files with 19 additions and 130 deletions

View file

@ -19,18 +19,13 @@ pub struct StyleBloom {
/// Note that the use we do for them is safe, since the data we access from
/// them is completely read-only during restyling.
elements: Vec<UnsafeNode>,
/// A monotonic counter incremented which each reflow in order to invalidate
/// the bloom filter if appropriate.
generation: u32,
}
impl StyleBloom {
pub fn new(generation: u32) -> Self {
pub fn new() -> Self {
StyleBloom {
filter: Box::new(BloomFilter::new()),
elements: vec![],
generation: generation,
}
}
@ -38,10 +33,6 @@ impl StyleBloom {
&*self.filter
}
pub fn generation(&self) -> u32 {
self.generation
}
pub fn maybe_pop<E>(&mut self, element: E)
where E: TElement + MatchMethods
{
@ -129,14 +120,12 @@ impl StyleBloom {
/// Returns the new bloom filter depth.
pub fn insert_parents_recovering<E>(&mut self,
element: E,
element_depth: Option<usize>,
generation: u32)
element_depth: Option<usize>)
-> usize
where E: TElement,
{
// Easy case, we're in a different restyle, or we're empty.
if self.generation != generation || self.elements.is_empty() {
self.generation = generation;
if self.elements.is_empty() {
return self.rebuild(element);
}