diff options
author | Bobby Holley <bobbyholley@gmail.com> | 2017-05-27 12:56:53 +0200 |
---|---|---|
committer | Bobby Holley <bobbyholley@gmail.com> | 2017-06-21 19:53:15 -0700 |
commit | 0f0e0d81fbed3c29bb10a452a294487f21b4e66c (patch) | |
tree | be899d8edbcea46a3ddf136796ddc4ed50557882 /components/style/bloom.rs | |
parent | ed5485ed18535a1de9401c7c9499be26292e76fc (diff) | |
download | servo-0f0e0d81fbed3c29bb10a452a294487f21b4e66c.tar.gz servo-0f0e0d81fbed3c29bb10a452a294487f21b4e66c.zip |
Push elements in order in StyleBloom::rebuilds.
This is important because we're about to start storing a parallel list
of pushed hashes, and the current behavior here will cause mismatches
there.
We take the opportunity to bump the SmallVec size to 16, since each
entry is only a word and we really want to avoid heap-allocating. And
then we switch to drain(), because of
https://github.com/rust-lang/rust/issues/42763
Diffstat (limited to 'components/style/bloom.rs')
-rw-r--r-- | components/style/bloom.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/components/style/bloom.rs b/components/style/bloom.rs index c63cf88a76e..07d245a1e4a 100644 --- a/components/style/bloom.rs +++ b/components/style/bloom.rs @@ -139,13 +139,15 @@ impl<E: TElement> StyleBloom<E> { pub fn rebuild(&mut self, mut element: E) { self.clear(); + let mut parents_to_insert = SmallVec::<[E; 16]>::new(); while let Some(parent) = element.traversal_parent() { - self.push_internal(parent); + parents_to_insert.push(parent); element = parent; } - // Put them in the order we expect, from root to `element`'s parent. - self.elements.reverse(); + for parent in parents_to_insert.drain().rev() { + self.push(parent); + } } /// In debug builds, asserts that all the parents of `element` are in the @@ -238,7 +240,7 @@ impl<E: TElement> StyleBloom<E> { // Let's collect the parents we are going to need to insert once we've // found the common one. - let mut parents_to_insert = SmallVec::<[E; 8]>::new(); + let mut parents_to_insert = SmallVec::<[E; 16]>::new(); // If the bloom filter still doesn't have enough elements, the common // parent is up in the dom. @@ -284,7 +286,7 @@ impl<E: TElement> StyleBloom<E> { // Now the parents match, so insert the stack of elements we have been // collecting so far. - for parent in parents_to_insert.into_iter().rev() { + for parent in parents_to_insert.drain().rev() { self.push(parent); } |