Bug 1457030: Remove elements from the mNodesToDestroy array back to front, preventing expensive memmoves on large amounts of reuse. r=kats
authorBas Schouten <bschouten@mozilla.com>
Thu, 26 Apr 2018 18:50:23 +0200
changeset 471941 5644d7852eb834b07ba125662af23fad75013d19
parent 471940 ac68dde791890802488aa0f4129b2458ec520395
child 471942 36a7b939360d52deb4eb959a7aee52a7d06741eb
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1457030
milestone61.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 1457030: Remove elements from the mNodesToDestroy array back to front, preventing expensive memmoves on large amounts of reuse. r=kats MozReview-Commit-ID: DZ1H9KIuDUp
gfx/layers/apz/src/APZCTreeManager.cpp
--- a/gfx/layers/apz/src/APZCTreeManager.cpp
+++ b/gfx/layers/apz/src/APZCTreeManager.cpp
@@ -726,20 +726,20 @@ GetEventRegions(const ScrollNode& aLayer
 already_AddRefed<HitTestingTreeNode>
 APZCTreeManager::RecycleOrCreateNode(TreeBuildingState& aState,
                                      AsyncPanZoomController* aApzc,
                                      LayersId aLayersId)
 {
   // Find a node without an APZC and return it. Note that unless the layer tree
   // actually changes, this loop should generally do an early-return on the
   // first iteration, so it should be cheap in the common case.
-  for (size_t i = 0; i < aState.mNodesToDestroy.Length(); i++) {
+  for (int32_t i = aState.mNodesToDestroy.Length() - 1; i >= 0; i--) {
     RefPtr<HitTestingTreeNode> node = aState.mNodesToDestroy[i];
     if (!node->IsPrimaryHolder()) {
-      aState.mNodesToDestroy.RemoveElement(node);
+      aState.mNodesToDestroy.RemoveElementAt(i);
       node->RecycleWith(aApzc, aLayersId);
       return node.forget();
     }
   }
   RefPtr<HitTestingTreeNode> node = new HitTestingTreeNode(aApzc, false, aLayersId);
   return node.forget();
 }