Bug 1369187: style: Use ArrayVec for the pseudo-elements we need to restyle. r?bholley draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 31 May 2017 17:15:54 +0200
changeset 587383 fe3c8d0df07811235ad3857f7e9e46561b019b8d
parent 587382 e7a140000038331244a14cc4cc689ae20e40a36f
child 587384 106812a7d2643c10c1bbccce47b23fe5b7bf3922
push id61681
push userbmo:emilio+bugs@crisal.io
push dateWed, 31 May 2017 21:41:57 +0000
reviewersbholley
bugs1369187
milestone55.0a1
Bug 1369187: style: Use ArrayVec for the pseudo-elements we need to restyle. r?bholley Just a drive-by, easy optimization. MozReview-Commit-ID: AVaeWvBHLzc
servo/components/style/data.rs
--- a/servo/components/style/data.rs
+++ b/servo/components/style/data.rs
@@ -1,14 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 //! Per-node data used in style calculation.
 
+use arrayvec::ArrayVec;
 use context::SharedStyleContext;
 use dom::TElement;
 use properties::{AnimationRules, ComputedValues, PropertyDeclarationBlock};
 use properties::longhands::display::computed_value as display;
 use restyle_hints::{HintComputationContext, RestyleReplacements, RestyleHint};
 use rule_tree::StrongRuleNode;
 use selector_parser::{EAGER_PSEUDO_COUNT, PseudoElement, RestyleDamage};
 use selectors::matching::VisitedHandlingMode;
@@ -188,18 +189,18 @@ impl EagerPseudoStyles {
         let empty = self.0.as_ref().unwrap().iter().all(|x| x.is_none());
         if empty {
             self.0 = None;
         }
         result
     }
 
     /// Returns a list of the pseudo-elements.
-    pub fn keys(&self) -> Vec<PseudoElement> {
-        let mut v = Vec::new();
+    pub fn keys(&self) -> ArrayVec<[PseudoElement; EAGER_PSEUDO_COUNT]> {
+        let mut v = ArrayVec::new();
         if let Some(ref arr) = self.0 {
             for i in 0..EAGER_PSEUDO_COUNT {
                 if arr[i].is_some() {
                     v.push(PseudoElement::from_eager_index(i));
                 }
             }
         }
         v