Bug 1420928 - Templatize functions that ensures nsStyleAutoArray length. r=boris
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Fri, 05 Jan 2018 06:24:10 +0900
changeset 449659 96c9efcb4a31b996cb92cf8fc56a9c3764f91250
parent 449658 f61cba8c98432dec452984c5ca75221195a9deb7
child 449660 df1519b33fe0e809f40a155c8a490b2f07d66cfe
child 449693 08b45ade75ed26f7f1cb0c0205caba2558a88912
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersboris
bugs1420928
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1420928 - Templatize functions that ensures nsStyleAutoArray length. r=boris MozReview-Commit-ID: 7MvW9OCBkCP
layout/style/ServoBindings.cpp
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -1797,44 +1797,43 @@ Gecko_EnsureImageLayersLength(nsStyleIma
 
   aLayers->mLayers.EnsureLengthAtLeast(aLen);
 
   for (size_t i = oldLength; i < aLen; ++i) {
     aLayers->mLayers[i].Initialize(aLayerType);
   }
 }
 
+template <typename StyleType>
+static void
+EnsureStyleAutoArrayLength(StyleType* aArray, size_t aLen)
+{
+  size_t oldLength = aArray->Length();
+
+  aArray->EnsureLengthAtLeast(aLen);
+
+  for (size_t i = oldLength; i < aLen; ++i) {
+    (*aArray)[i].SetInitialValues();
+  }
+}
+
 void
 Gecko_EnsureStyleAnimationArrayLength(void* aArray, size_t aLen)
 {
   auto base =
     static_cast<nsStyleAutoArray<StyleAnimation>*>(aArray);
-
-  size_t oldLength = base->Length();
-
-  base->EnsureLengthAtLeast(aLen);
-
-  for (size_t i = oldLength; i < aLen; ++i) {
-    (*base)[i].SetInitialValues();
-  }
+  EnsureStyleAutoArrayLength(base, aLen);
 }
 
 void
 Gecko_EnsureStyleTransitionArrayLength(void* aArray, size_t aLen)
 {
   auto base =
     reinterpret_cast<nsStyleAutoArray<StyleTransition>*>(aArray);
-
-  size_t oldLength = base->Length();
-
-  base->EnsureLengthAtLeast(aLen);
-
-  for (size_t i = oldLength; i < aLen; ++i) {
-    (*base)[i].SetInitialValues();
-  }
+  EnsureStyleAutoArrayLength(base, aLen);
 }
 
 void
 Gecko_ClearWillChange(nsStyleDisplay* aDisplay, size_t aLength)
 {
   aDisplay->mWillChange.Clear();
   aDisplay->mWillChange.SetCapacity(aLength);
 }