Index: src/profile-generator.cc |
diff --git a/src/profile-generator.cc b/src/profile-generator.cc |
index 640f13cd62ceb33c227ca2e5d7101ca68ca7c2eb..1bb22be03de0409bcfb4e2c44c8cef989e5a7ae8 100644 |
--- a/src/profile-generator.cc |
+++ b/src/profile-generator.cc |
@@ -1544,6 +1544,28 @@ HeapSnapshotsDiff* HeapSnapshot::CompareWith(HeapSnapshot* snapshot) { |
} |
+HeapEntry* HeapSnapshot::GetEntryById(uint64_t id) { |
+ // GetSortedEntriesList is used in diff algorithm and sorts |
+ // entries by their id. |
+ List<HeapEntry*>* entries_by_id = GetSortedEntriesList(); |
+ |
+ // Perform a binary search by id. |
+ int low = 0; |
+ int high = entries_by_id->length() - 1; |
+ while (low <= high) { |
+ int mid = ((unsigned int)low + (unsigned int)high) >> 1; |
Søren Thygesen Gjesse
2010/12/02 07:37:15
No C-style casts please.
mnaganov (inactive)
2010/12/02 15:38:25
Done.
|
+ uint64_t mid_id = entries_by_id->at(mid)->id(); |
+ if (mid_id > id) |
+ high = mid - 1; |
+ else if (mid_id < id) |
+ low = mid + 1; |
+ else |
+ return entries_by_id->at(mid); |
+ } |
+ return NULL; |
+} |
+ |
+ |
List<HeapGraphPath*>* HeapSnapshot::GetRetainingPaths(HeapEntry* entry) { |
HashMap::Entry* p = |
retaining_paths_.Lookup(entry, HeapEntry::Hash(entry), true); |