Index: tools/codemap.js |
diff --git a/tools/codemap.js b/tools/codemap.js |
index d7c52e8298bacf84c59532dcd6c9f3f778b9f14d..f8a4f593f07aa5fbac1f716ef0120c5a15832451 100644 |
--- a/tools/codemap.js |
+++ b/tools/codemap.js |
@@ -79,7 +79,7 @@ CodeMap.PAGE_SIZE = |
* @param {CodeMap.CodeEntry} codeEntry Code entry object. |
*/ |
CodeMap.prototype.addCode = function(start, codeEntry) { |
- this.removeAllCoveredNodes_(this.dynamics_, start, start + codeEntry.size); |
+ this.deleteAllCoveredNodes_(this.dynamics_, start, start + codeEntry.size); |
this.dynamics_.insert(start, codeEntry); |
}; |
@@ -94,7 +94,7 @@ CodeMap.prototype.addCode = function(start, codeEntry) { |
CodeMap.prototype.moveCode = function(from, to) { |
if (from === to) return; |
var removedNode = this.dynamics_.remove(from); |
- this.removeAllCoveredNodes_(this.dynamics_, to, to + removedNode.value.size); |
+ this.deleteAllCoveredNodes_(this.dynamics_, to, to + removedNode.value.size); |
this.dynamics_.insert(to, removedNode.value); |
}; |
@@ -149,28 +149,25 @@ CodeMap.prototype.markPages_ = function(start, end) { |
/** |
* @private |
*/ |
-CodeMap.prototype.isAddressBelongsTo_ = function(addr, node) { |
- return addr >= node.key && addr < (node.key + node.value.size); |
+CodeMap.prototype.deleteAllCoveredNodes_ = function(tree, start, end) { |
+ var to_delete = []; |
+ var addr = end - 1; |
+ while (addr >= start) { |
+ var node = tree.findGreatestLessThan(addr); |
+ if (!node) break; |
+ var start2 = node.key, end2 = start2 + node.value.size; |
+ if (start2 < end && start < end2) to_delete.push(start2); |
+ addr = start2 - 1; |
+ } |
+ for (var i = 0, l = to_delete.length; i < l; ++i) tree.remove(to_delete[i]); |
}; |
/** |
* @private |
*/ |
-CodeMap.prototype.findAllCoveredNodes_ = function(tree, start, end) { |
- var result = []; |
- var addr = end - 1; |
- while (addr >= start) { |
- var node = tree.findGreatestLessThan(addr); |
- if (!node) break; |
- var start2 = node.key, end2 = node.key + node.value.size; |
- if (start2 < end && start < end2) { |
- // Node overlaps with the interval given |
- result.push(node); |
- } |
- addr = node.key - 1; |
- } |
- return result; |
+CodeMap.prototype.isAddressBelongsTo_ = function(addr, node) { |
+ return addr >= node.key && addr < (node.key + node.value.size); |
}; |
@@ -257,14 +254,6 @@ CodeMap.prototype.getAllLibrariesEntries = function() { |
}; |
-CodeMap.prototype.removeAllCoveredNodes_ = function(tree, start, end) { |
- var covered = this.findAllCoveredNodes_(tree, start, end); |
- for (var i = 0, l = covered.length; i < l; ++i) { |
- tree.remove(covered[i].key); |
- } |
-}; |
- |
- |
/** |
* Creates a code entry object. |
* |