From 1cea4e7942d1f14ac68223d509cce37e6fd98480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 19 May 2017 04:59:51 +0200 Subject: [PATCH] style: Use a SmallVec for common ancestors in the bloom filter. --- components/style/bloom.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/components/style/bloom.rs b/components/style/bloom.rs index 7633d154fe8..f5df67e6a3f 100644 --- a/components/style/bloom.rs +++ b/components/style/bloom.rs @@ -9,6 +9,7 @@ use dom::{SendElement, TElement}; use selectors::bloom::BloomFilter; +use smallvec::SmallVec; /// A struct that allows us to fast-reject deep descendant selectors avoiding /// selector-matching. @@ -223,7 +224,7 @@ impl StyleBloom { // Let's collect the parents we are going to need to insert once we've // found the common one. - let mut parents_to_insert = vec![]; + let mut parents_to_insert = SmallVec::<[E; 8]>::new(); // If the bloom filter still doesn't have enough elements, the common // parent is up in the dom. @@ -245,10 +246,12 @@ impl StyleBloom { // Not-so-happy case: Parent's don't match, so we need to keep going up // until we find a common ancestor. // - // Gecko currently models native anonymous content that conceptually hangs - // off the document (such as scrollbars) as a separate subtree from the - // document root. Thus it's possible with Gecko that we do not find any - // common ancestor. + // Gecko currently models native anonymous content that conceptually + // hangs off the document (such as scrollbars) as a separate subtree + // from the document root. + // + // Thus it's possible with Gecko that we do not find any common + // ancestor. while **self.elements.last().unwrap() != common_parent { parents_to_insert.push(common_parent); self.pop().unwrap();