Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Unified Diff: Source/devtools/front_end/HeapSnapshot.js

Issue 205953002: Revert of Remove WebInspector.HeapSnapshotArraySlice (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/inspector/profiler/heap-snapshot-test.js ('k') | Source/devtools/front_end/JSHeapSnapshot.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/HeapSnapshot.js
diff --git a/Source/devtools/front_end/HeapSnapshot.js b/Source/devtools/front_end/HeapSnapshot.js
index 12b186b808ba0a92f771c70ff81ec941b48b62a4..bd30745c4b9f24182c844736b26bc84eba82ba56 100644
--- a/Source/devtools/front_end/HeapSnapshot.js
+++ b/Source/devtools/front_end/HeapSnapshot.js
@@ -30,8 +30,42 @@
/**
* @constructor
- * @param {!WebInspector.HeapSnapshot} snapshot
- * @param {!Uint32Array} edges
+ * @param {!Uint32Array} array
+ * @param {number} start
+ * @param {number} end
+ */
+WebInspector.HeapSnapshotArraySlice = function(array, start, end)
+{
+ this._array = array;
+ this._start = start;
+ this.length = end - start;
+}
+
+WebInspector.HeapSnapshotArraySlice.prototype = {
+ /**
+ * @param {number} index
+ * @return {number}
+ */
+ item: function(index)
+ {
+ return this._array[this._start + index];
+ },
+
+ /**
+ * @param {number} start
+ * @param {number=} end
+ * @return {!Uint32Array}
+ */
+ slice: function(start, end)
+ {
+ if (typeof end === "undefined")
+ end = this.length;
+ return this._array.subarray(this._start + start, this._start + end);
+ }
+}
+
+/**
+ * @constructor
* @param {number=} edgeIndex
*/
WebInspector.HeapSnapshotEdge = function(snapshot, edges, edgeIndex)
@@ -95,7 +129,15 @@
*/
nodeIndex: function()
{
- return this._edges[this.edgeIndex + this._snapshot._edgeToNodeOffset];
+ return this._edges.item(this.edgeIndex + this._snapshot._edgeToNodeOffset);
+ },
+
+ /**
+ * @return {!Array.<number>}
+ */
+ rawEdges: function()
+ {
+ return this._edges;
},
/**
@@ -125,7 +167,7 @@
_type: function()
{
- return this._edges[this.edgeIndex + this._snapshot._edgeTypeOffset];
+ return this._edges.item(this.edgeIndex + this._snapshot._edgeTypeOffset);
}
};
@@ -481,11 +523,11 @@
},
/**
- * @return {!Uint32Array}
+ * @return {!WebInspector.HeapSnapshotArraySlice}
*/
rawEdges: function()
{
- return this._snapshot._containmentEdges.subarray(this._edgeIndexesStart(), this._edgeIndexesEnd());
+ return new WebInspector.HeapSnapshotArraySlice(this._snapshot._containmentEdges, this._edgeIndexesStart(), this._edgeIndexesEnd());
},
/**
@@ -956,15 +998,11 @@
return this._firstDominatedNodeIndex[nodeIndex / this._nodeFieldCount];
},
- /**
- * @param {!WebInspector.HeapSnapshotNode} node
- * @return {!Uint32Array}
- */
_dominatedNodesOfNode: function(node)
{
var dominatedIndexFrom = this._getDominatedIndex(node.nodeIndex);
var dominatedIndexTo = this._getDominatedIndex(node._nextNodeIndex());
- return this._dominatedNodes.subarray(dominatedIndexFrom, dominatedIndexTo);
+ return new WebInspector.HeapSnapshotArraySlice(this._dominatedNodes, dominatedIndexFrom, dominatedIndexTo);
},
/**
@@ -1892,14 +1930,13 @@
/**
* @constructor
- * @param {(!Array.<number>|!Uint32Array)=} unfilteredIterationOrder
+ * @param {!Array.<number>=} unfilteredIterationOrder
*/
WebInspector.HeapSnapshotFilteredOrderedIterator = function(iterator, filter, unfilteredIterationOrder)
{
this._filter = filter;
this._iterator = iterator;
this._unfilteredIterationOrder = unfilteredIterationOrder;
- /** @type {?Array.<number>|?Uint32Array} */
this._iterationOrder = null;
this._position = 0;
this._currentComparator = null;
@@ -1913,7 +1950,7 @@
if (this._iterationOrder)
return;
if (this._unfilteredIterationOrder && !this._filter) {
- this._iterationOrder = this._unfilteredIterationOrder;
+ this._iterationOrder = this._unfilteredIterationOrder.slice(0);
this._unfilteredIterationOrder = null;
return;
}
@@ -1928,7 +1965,8 @@
this._iterationOrder.push(iterator.index());
}
} else {
- var order = this._unfilteredIterationOrder;
+ var order = this._unfilteredIterationOrder.constructor === Array ?
+ this._unfilteredIterationOrder : this._unfilteredIterationOrder.slice(0);
for (var i = 0, l = order.length; i < l; ++i) {
iterator.setIndex(order[i]);
if (this._filter(iterator.item()))
@@ -1969,7 +2007,8 @@
if (this._filter(iterator.item()))
return false;
} else {
- var order = this._unfilteredIterationOrder;
+ var order = this._unfilteredIterationOrder.constructor === Array ?
+ this._unfilteredIterationOrder : this._unfilteredIterationOrder.slice(0);
for (var i = 0, l = order.length; i < l; ++i) {
iterator.setIndex(order[i]);
if (this._filter(iterator.item()))
@@ -2139,7 +2178,7 @@
/**
* @constructor
* @extends {WebInspector.HeapSnapshotFilteredOrderedIterator}
- * @param {(!Array.<number>|!Uint32Array)=} nodeIndexes
+ * @param {!Array.<number>=} nodeIndexes
*/
WebInspector.HeapSnapshotNodesProvider = function(snapshot, filter, nodeIndexes)
{
« no previous file with comments | « LayoutTests/inspector/profiler/heap-snapshot-test.js ('k') | Source/devtools/front_end/JSHeapSnapshot.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698