Bug 1096537 - Remove manually choosing the start index in `ThreadNode.prototype.insert`, r=fitzgen
authorVictor Porof <vporof@mozilla.com>
Sun, 16 Nov 2014 10:09:34 -0500
changeset 240314 8c234419490d6b6ca9d6060a5c621c56087b1a45
parent 240313 dd555a81cbbaa728b42b92661e1a6454ab1b2cfb
child 240315 7fe78086ac8a66937fa1a49dbf8418edefa4d25c
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfitzgen
bugs1096537
milestone36.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 1096537 - Remove manually choosing the start index in `ThreadNode.prototype.insert`, r=fitzgen
browser/devtools/profiler/utils/tree-model.js
--- a/browser/devtools/profiler/utils/tree-model.js
+++ b/browser/devtools/profiler/utils/tree-model.js
@@ -77,53 +77,47 @@ ThreadNode.prototype = {
    * @param number beginAt [optional]
    *        The earliest sample to start at (in milliseconds).
    * @param number endAt [optional]
    *        The latest sample to end at (in milliseconds).
    * @param boolean inverted [optional]
    *        Specifies if the call tree should be inverted (youngest -> oldest
    *        frames).
    */
-  insert: function(sample, contentOnly = false, beginAt = 0, endAt = Infinity,
-                   inverted = false) {
+  insert: function(sample, contentOnly = false, beginAt = 0, endAt = Infinity, inverted = false) {
     let sampleTime = sample.time;
     if (!sampleTime || sampleTime < beginAt || sampleTime > endAt) {
       return;
     }
 
     let sampleFrames = sample.frames;
 
     // Filter out platform frames if only content-related function calls
     // should be taken into consideration.
     if (contentOnly) {
+      // The (root) node is not considered a content function, it'll be removed.
       sampleFrames = sampleFrames.filter(isContent);
+    } else {
+      // Remove the (root) node manually.
+      sampleFrames = sampleFrames.slice(1);
     }
-
     if (!sampleFrames.length) {
       return;
     }
-
     if (inverted) {
       sampleFrames.reverse();
-      if (!contentOnly) {
-        // Remove the (root) node -- we don't want it as a leaf in the inverted
-        // tree.
-        sampleFrames.pop();
-      }
     }
 
-    let startIndex = (inverted || contentOnly) ? 0 : 1;
-
     let sampleDuration = sampleTime - this._previousSampleTime;
     this._previousSampleTime = sampleTime;
     this.samples++;
     this.duration += sampleDuration;
 
     FrameNode.prototype.insert(
-      sampleFrames, startIndex, sampleTime, sampleDuration, this.calls);
+      sampleFrames, 0, sampleTime, sampleDuration, this.calls);
   },
 
   /**
    * Gets additional details about this node.
    * @return object
    */
   getInfo: function() {
     return {