Title: [110989] trunk/Source/WebCore
Revision
110989
Author
[email protected]
Date
2012-03-16 04:55:32 -0700 (Fri, 16 Mar 2012)

Log Message

Web Inspector: HeapSnapshot: speedup buildReverseIndex.
https://bugs.webkit.org/show_bug.cgi?id=81327

Reviewed by Yury Semikhatsky.

* inspector/front-end/HeapSnapshot.js:
(WebInspector.HeapSnapshot.prototype.get maxNodeId):
(WebInspector.HeapSnapshot.prototype._buildNodeIndex):
(WebInspector.HeapSnapshot.prototype._findNearestNodeIndex):
(WebInspector.HeapSnapshot.prototype._getRetainerIndex):
(WebInspector.HeapSnapshot.prototype._buildDominatedNodes):
(WebInspector.HeapSnapshot.prototype):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (110988 => 110989)


--- trunk/Source/WebCore/ChangeLog	2012-03-16 11:41:06 UTC (rev 110988)
+++ trunk/Source/WebCore/ChangeLog	2012-03-16 11:55:32 UTC (rev 110989)
@@ -1,3 +1,18 @@
+2012-03-16  Ilya Tikhonovsky  <[email protected]>
+
+        Web Inspector: HeapSnapshot: speedup buildReverseIndex.
+        https://bugs.webkit.org/show_bug.cgi?id=81327
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/front-end/HeapSnapshot.js:
+        (WebInspector.HeapSnapshot.prototype.get maxNodeId):
+        (WebInspector.HeapSnapshot.prototype._buildNodeIndex):
+        (WebInspector.HeapSnapshot.prototype._findNearestNodeIndex):
+        (WebInspector.HeapSnapshot.prototype._getRetainerIndex):
+        (WebInspector.HeapSnapshot.prototype._buildDominatedNodes):
+        (WebInspector.HeapSnapshot.prototype):
+
 2012-03-16  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r110976.

Modified: trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js (110988 => 110989)


--- trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js	2012-03-16 11:41:06 UTC (rev 110988)
+++ trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js	2012-03-16 11:55:32 UTC (rev 110989)
@@ -845,7 +845,7 @@
             return this._maxNodeId;
         this._maxNodeId = 0;
         var node = new WebInspector.HeapSnapshotNode(this, this.nodeIndexes[0]);
-        for (var i = 0; i < this.nodeCount; ++i) {
+        for (var i = 0, l = this.nodeCount; i < l; ++i) {
             node.nodeIndex = this.nodeIndexes[i];
             var id = node.id;
             if ((id % 2) && id > this._maxNodeId)
@@ -968,7 +968,7 @@
             (function (node, callback)
              {
                  for (var edgesIter = node.edges; edgesIter.hasNext(); edgesIter.next())
-                     callback(this._findNodePositionInIndex(edgesIter.edge.nodeIndex));
+                     callback(this._nodePosition[edgesIter.edge.nodeIndex]);
              }).bind(this),
             (function (node, indexCallback, dataCallback)
              {
@@ -1037,7 +1037,7 @@
         var aggregates = {};
         var aggregatesByClassName = {};
         var node = new WebInspector.HeapSnapshotNode(this, this.nodeIndexes[0]);
-        for (var i = 0; i < this.nodeCount; ++i) {
+        for (var i = 0, l = this.nodeCount; i < l; ++i) {
             node.nodeIndex = this.nodeIndexes[i];
             var classIndex = node.classIndex;
             if (shouldSkip(node, classIndex))
@@ -1106,21 +1106,22 @@
     {
         var count = 0;
         for (var nodesIter = this._allNodes; nodesIter.hasNext(); nodesIter.next(), ++count);
-        this._nodeIndex = new Int32Array(count + 1);
+        var nodeIndex = new Int32Array(count + 1);
+        var nodePosition = {};
         count = 0;
-        for (var nodesIter = this._allNodes; nodesIter.hasNext(); nodesIter.next(), ++count)
-            this._nodeIndex[count] = nodesIter.index;
-        this._nodeIndex[count] = this._nodes.length;
+        for (var nodesIter = this._allNodes; nodesIter.hasNext(); nodesIter.next(), ++count) {
+            nodeIndex[count] = nodesIter.index;
+            nodePosition[nodesIter.index] = count;
+        }
+        nodeIndex[count] = this._nodes.length;
+        nodePosition[this._nodes.length] = count;
+        this._nodeIndex = nodeIndex;
+        this._nodePosition = nodePosition;
     },
 
-    _findNodePositionInIndex: function(index)
-    {
-        return binarySearch(index, this._nodeIndex, this._numbersComparator);
-    },
-
     _findNearestNodeIndex: function(index)
     {
-        var result = this._findNodePositionInIndex(index);
+        var result = binarySearch(index, this._nodeIndex, this._numbersComparator);
         if (result < 0) {
             result = -result - 1;
             nodeIndex = this._nodeIndex[result];
@@ -1134,7 +1135,7 @@
 
     _getRetainerIndex: function(nodeIndex)
     {
-        var nodePosition = this._findNodePositionInIndex(nodeIndex);
+        var nodePosition = this._nodePosition[nodeIndex];
         return this._retainerIndex[nodePosition];
     },
 
@@ -1147,7 +1148,7 @@
              {
                  var dominatorIndex = node.dominatorIndex;
                  if (dominatorIndex !== node.nodeIndex)
-                     callback(this._findNodePositionInIndex(dominatorIndex));
+                     callback(this._nodePosition[dominatorIndex]);
              }).bind(this),
             (function (node, indexCallback, dataCallback)
              {
@@ -1161,7 +1162,7 @@
 
     _getDominatedIndex: function(nodeIndex)
     {
-        var nodePosition = this._findNodePositionInIndex(nodeIndex);
+        var nodePosition = this._nodePosition[nodeIndex];
         return this._dominatedIndex[nodePosition];
     },
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to