Bug 1275887 - Remove longPropIterator/shortPropIterator in reps. r=odvarko
authorDalimil Hajek <dalimilhajek@gmail.com>
Wed, 20 Jul 2016 06:22:00 -0400
changeset 331212 9728fac2aed064f6dc9ed03fb35f84219e885a19
parent 331211 7378c226537699f13ef6a2d62bdc4f4e128b48a8
child 331213 7436d69f220b218af483cd88932f6a497f41c349
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersodvarko
bugs1275887
milestone50.0a1
Bug 1275887 - Remove longPropIterator/shortPropIterator in reps. r=odvarko
devtools/client/shared/components/reps/grip.js
devtools/client/shared/components/reps/object.js
--- a/devtools/client/shared/components/reps/grip.js
+++ b/devtools/client/shared/components/reps/grip.js
@@ -34,28 +34,20 @@ define(function (require, exports, modul
       if (this.props.objectLink) {
         return this.props.objectLink({
           object: object
         }, object.class);
       }
       return object.class || "Object";
     },
 
-    longPropIterator: function (object) {
+    safePropIterator: function (object, max) {
+      max = (typeof max === "undefined") ? 3 : max;
       try {
-        return this.propIterator(object, 100);
-      } catch (err) {
-        console.error(err);
-      }
-      return [];
-    },
-
-    shortPropIterator: function (object) {
-      try {
-        return this.propIterator(object, 3);
+        return this.propIterator(object, max);
       } catch (err) {
         console.error(err);
       }
       return [];
     },
 
     propIterator: function (object, max) {
       // Property filter. Show only interesting properties to the user.
@@ -147,19 +139,18 @@ define(function (require, exports, modul
         console.error(err);
       }
 
       return props;
     },
 
     render: function () {
       let object = this.props.object;
-      let props = (this.props.mode == "long") ?
-        this.longPropIterator(object) :
-        this.shortPropIterator(object);
+      let props = this.safePropIterator(object,
+        (this.props.mode == "long") ? 100 : 3);
 
       let objectLink = this.props.objectLink || span;
       if (this.props.mode == "tiny" || !props.length) {
         return (
           ObjectBox({className: "object"},
             this.getTitle(object),
             objectLink({
               className: "objectLeftBrace",
--- a/devtools/client/shared/components/reps/object.js
+++ b/devtools/client/shared/components/reps/object.js
@@ -31,28 +31,20 @@ define(function (require, exports, modul
       if (this.props.objectLink) {
         return this.props.objectLink({
           object: object
         }, object.class);
       }
       return "Object";
     },
 
-    longPropIterator: function (object) {
+    safePropIterator: function (object, max) {
+      max = (typeof max === "undefined") ? 3 : max;
       try {
-        return this.propIterator(object, 100);
-      } catch (err) {
-        console.error(err);
-      }
-      return [];
-    },
-
-    shortPropIterator: function (object) {
-      try {
-        return this.propIterator(object, 3);
+        return this.propIterator(object, max);
       } catch (err) {
         console.error(err);
       }
       return [];
     },
 
     propIterator: function (object, max) {
       let isInterestingProp = (t, value) => {
@@ -136,17 +128,17 @@ define(function (require, exports, modul
         console.error(err);
       }
 
       return props;
     },
 
     render: function () {
       let object = this.props.object;
-      let props = this.shortPropIterator(object);
+      let props = this.safePropIterator(object);
       let objectLink = this.props.objectLink || span;
 
       if (this.props.mode == "tiny" || !props.length) {
         return (
           ObjectBox({className: "object"},
             objectLink({className: "objectTitle"}, this.getTitle())
           )
         );