mirror of
https://github.com/servo/servo.git
synced 2025-08-08 23:15:33 +01:00
Hoist bloom filter into scoped TLS and simplify code.
This commit is contained in:
parent
25f32c4513
commit
b6e948dc5d
7 changed files with 19 additions and 130 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue