Bug 1371958 part 1 - Use EnsureRemoved instead of Contains+RemoveEntry to avoid an unnecessary hashtable lookup. r=froydnj
authorMats Palmgren <mats@mozilla.com>
Sat, 17 Jun 2017 00:06:04 +0200
changeset 364520 888cb6362ed8cdf4145a81cdfcc7d19bd3d74ffa
parent 364519 8b2c36d660c2c39dd14f582778de9319193c6e6d
child 364521 59b1fd575d3dd38dca223d5b7347be23b397a9d1
push id32043
push userarchaeopteryx@coole-files.de
push dateSat, 17 Jun 2017 20:28:42 +0000
treeherdermozilla-central@0ef3bfc9f4b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1371958
milestone56.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 1371958 part 1 - Use EnsureRemoved instead of Contains+RemoveEntry to avoid an unnecessary hashtable lookup. r=froydnj MozReview-Commit-ID: 6SPQrQCLBjF
layout/painting/FrameLayerBuilder.cpp
--- a/layout/painting/FrameLayerBuilder.cpp
+++ b/layout/painting/FrameLayerBuilder.cpp
@@ -2308,24 +2308,27 @@ ContainerState::GetLayerCreationHint(Ani
 }
 
 already_AddRefed<PaintedLayer>
 ContainerState::AttemptToRecyclePaintedLayer(AnimatedGeometryRoot* aAnimatedGeometryRoot,
                                              nsDisplayItem* aItem,
                                              const nsPoint& aTopLeft)
 {
   Layer* oldLayer = mLayerBuilder->GetOldLayerFor(aItem);
-  if (!oldLayer || !oldLayer->AsPaintedLayer() ||
-      !mPaintedLayersAvailableForRecycling.Contains(oldLayer->AsPaintedLayer())) {
+  if (!oldLayer || !oldLayer->AsPaintedLayer()) {
     return nullptr;
   }
 
-  // Try to recycle a layer
+  if (!mPaintedLayersAvailableForRecycling.EnsureRemoved(oldLayer->AsPaintedLayer())) {
+    // Not found.
+    return nullptr;
+  }
+
+  // Try to recycle the layer.
   RefPtr<PaintedLayer> layer = oldLayer->AsPaintedLayer();
-  mPaintedLayersAvailableForRecycling.RemoveEntry(layer);
 
   // Check if the layer hint has changed and whether or not the layer should
   // be recreated because of it.
   if (!layer->IsOptimizedFor(GetLayerCreationHint(aAnimatedGeometryRoot))) {
     return nullptr;
   }
 
   bool didResetScrollPositionForLayerPixelAlignment = false;