Bug 1603290 - Save a copy of view in the places tree to avoid slow get calls. r=mak
authorMark Banner <standard8@mozilla.com>
Mon, 16 Dec 2019 08:56:44 +0000
changeset 507053 51f016ea456e5d3d284944e93db88022328069fb
parent 507052 d3918dafc6a8695e8003d7cf15ba8a4f1e974943
child 507054 c53f0a1c8a8ec23c017433b7bc247676a62b3809
push id36922
push userncsoregi@mozilla.com
push dateMon, 16 Dec 2019 17:21:47 +0000
treeherdermozilla-central@27d0d6cc2131 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1603290
milestone73.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 1603290 - Save a copy of view in the places tree to avoid slow get calls. r=mak Differential Revision: https://phabricator.services.mozilla.com/D57275
browser/components/places/content/places-tree.js
--- a/browser/components/places/content/places-tree.js
+++ b/browser/components/places/content/places-tree.js
@@ -154,37 +154,29 @@
 
     get disableUserActions() {
       return this.getAttribute("disableUserActions") == "true";
     }
     /**
      * overriding
      */
     set view(val) {
+      // We save the view so that we can avoid expensive get calls when
+      // we need to get the view again.
+      this._view = val;
       /* eslint-disable no-undef */
       return Object.getOwnPropertyDescriptor(
         XULTreeElement.prototype,
         "view"
       ).set.call(this, val);
       /* eslint-enable no-undef */
     }
 
     get view() {
-      try {
-        /* eslint-disable no-undef */
-        return (
-          Object.getOwnPropertyDescriptor(
-            XULTreeElement.prototype,
-            "view"
-          ).get.call(this).wrappedJSObject || null
-        );
-        /* eslint-enable no-undef */
-      } catch (e) {
-        return null;
-      }
+      return this._view;
     }
 
     get associatedElement() {
       return this;
     }
 
     set flatList(val) {
       if (this.flatList != val) {
@@ -821,17 +813,17 @@
 
     buildContextMenu(aPopup) {
       this._contextMenuShown = true;
       return this.controller.buildContextMenu(aPopup);
     }
 
     destroyContextMenu(aPopup) {}
     disconnectedCallback() {
-      // Unregister the controllber before unlinking the view, otherwise it
+      // Unregister the controller before unlinking the view, otherwise it
       // may still try to update commands on a view with a null result.
       if (this._controller) {
         this._controller.terminate();
         this.controllers.removeController(this._controller);
       }
 
       if (this.view) {
         this.view.uninit();