Bug 1403642. Avoid an extra property table lookup. r=ethlin
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Fri, 29 Sep 2017 00:39:55 -0400
changeset 383725 3baddc8863b2898efff2f52db657e5d997ebf1b5
parent 383724 7bdc00f1e6877f2e83f38bbad48240e765847aca
child 383726 946b9c995ec331f4f96360409fd8d2fc49e46838
push id52342
push userarchaeopteryx@coole-files.de
push dateFri, 29 Sep 2017 09:50:06 +0000
treeherderautoland@1bdf078c4a14 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersethlin
bugs1403642
milestone58.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 1403642. Avoid an extra property table lookup. r=ethlin We can just call Get() and check the return value instead of calling Has()
gfx/layers/wr/WebRenderLayerManager.h
--- a/gfx/layers/wr/WebRenderLayerManager.h
+++ b/gfx/layers/wr/WebRenderLayerManager.h
@@ -207,23 +207,24 @@ public:
   CreateOrRecycleWebRenderUserData(nsDisplayItem* aItem, bool* aOutIsRecycled = nullptr)
   {
     MOZ_ASSERT(aItem);
     nsIFrame* frame = aItem->Frame();
     if (aOutIsRecycled) {
       *aOutIsRecycled = true;
     }
 
-    if (!frame->HasProperty(nsIFrame::WebRenderUserDataProperty())) {
-      frame->AddProperty(nsIFrame::WebRenderUserDataProperty(),
-                         new nsIFrame::WebRenderUserDataTable());
+    nsIFrame::WebRenderUserDataTable* userDataTable =
+      frame->GetProperty(nsIFrame::WebRenderUserDataProperty());
+
+    if (!userDataTable) {
+      userDataTable = new nsIFrame::WebRenderUserDataTable();
+      frame->AddProperty(nsIFrame::WebRenderUserDataProperty(), userDataTable);
     }
 
-    nsIFrame::WebRenderUserDataTable* userDataTable =
-      frame->GetProperty(nsIFrame::WebRenderUserDataProperty());
     RefPtr<WebRenderUserData>& data = userDataTable->GetOrInsert(aItem->GetPerFrameKey());
     if (!data || (data->GetType() != T::Type()) || !data->IsDataValid(this)) {
       // To recreate a new user data, we should remove the data from the table first.
       if (data) {
         data->RemoveFromTable();
       }
       data = new T(this, aItem, &mWebRenderUserDatas);
       mWebRenderUserDatas.PutEntry(data);