diff options
author | Bobby Holley <bobbyholley@gmail.com> | 2017-04-08 20:05:38 +0800 |
---|---|---|
committer | Bobby Holley <bobbyholley@gmail.com> | 2017-04-09 14:52:49 +0800 |
commit | 3f52052cf9699020326fb6d0f3965b0402d79beb (patch) | |
tree | a6825088f7bee3d5dbd203e304370c0fa3295b24 /components/style/bloom.rs | |
parent | 1b363ac9094594110908793c0e2af12cd011e55e (diff) | |
download | servo-3f52052cf9699020326fb6d0f3965b0402d79beb.tar.gz servo-3f52052cf9699020326fb6d0f3965b0402d79beb.zip |
Do the sequential traversal breadth-first.
While we're at it, we also eliminate the 'unknown' dom depth for the
bloom filter. Computing depth has negligible cost relative to the
amount of work we do setting up the bloom filter at a given depth.
Doing it once per traversal should be totally fine.
I originally separated the elimination of unknown dom depth from the
traversal changes, but I got bloom filter crashes on the intermediate
patch, presumably because I didn't properly fix the sequential traversal
for this case. Given that the final state is green, I just decided to
squash and move on.
Diffstat (limited to 'components/style/bloom.rs')
-rw-r--r-- | components/style/bloom.rs | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/components/style/bloom.rs b/components/style/bloom.rs index aba2d9fa5b8..e8ba95aeb94 100644 --- a/components/style/bloom.rs +++ b/components/style/bloom.rs @@ -99,7 +99,7 @@ impl<E: TElement> StyleBloom<E> { } /// Rebuilds the bloom filter up to the parent of the given element. - pub fn rebuild(&mut self, mut element: E) -> usize { + pub fn rebuild(&mut self, mut element: E) { self.clear(); while let Some(parent) = element.parent_element() { @@ -110,7 +110,6 @@ impl<E: TElement> StyleBloom<E> { // Put them in the order we expect, from root to `element`'s parent. self.elements.reverse(); - return self.elements.len(); } /// In debug builds, asserts that all the parents of `element` are in the @@ -139,12 +138,12 @@ impl<E: TElement> StyleBloom<E> { /// responsible to keep around if it wants to get an effective filter. pub fn insert_parents_recovering(&mut self, element: E, - element_depth: Option<usize>) - -> usize + element_depth: usize) { // Easy case, we're in a different restyle, or we're empty. if self.elements.is_empty() { - return self.rebuild(element); + self.rebuild(element); + return; } let parent_element = match element.parent_element() { @@ -152,23 +151,19 @@ impl<E: TElement> StyleBloom<E> { None => { // Yay, another easy case. self.clear(); - return 0; + return; } }; if self.elements.last().map(|el| **el) == Some(parent_element) { // Ta da, cache hit, we're all done. - return self.elements.len(); + return; } - let element_depth = match element_depth { - Some(depth) => depth, - // If we don't know the depth of `element`, we'd rather don't try - // fixing up the bloom filter, since it's quadratic. - None => { - return self.rebuild(element); - } - }; + if element_depth == 0 { + self.clear(); + return; + } // We should've early exited above. debug_assert!(element_depth != 0, @@ -250,6 +245,5 @@ impl<E: TElement> StyleBloom<E> { debug_assert_eq!(self.elements.len(), element_depth); // We're done! Easy. - return self.elements.len(); } } |