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

Unified Diff: components/metrics/leak_detector/ranked_set.h

Issue 1870233003: Record call site history in LeakDetectorImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clarify comments in RankedSet Created 4 years, 8 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
Index: components/metrics/leak_detector/ranked_set.h
diff --git a/components/metrics/leak_detector/ranked_set.h b/components/metrics/leak_detector/ranked_set.h
index f91251593b046147d5ed2f7ac99f77886ee50235..87c150e38a3ea7135cbd43877c899ae4368fda00 100644
--- a/components/metrics/leak_detector/ranked_set.h
+++ b/components/metrics/leak_detector/ranked_set.h
@@ -72,7 +72,20 @@ class RankedSet {
Add(ValueType(call_stack), count);
}
+ // Helper functions to directly search for an element with |value| equal to a
+ // particular size or call stack. The time complexity is O(n) rather than the
+ // O(log n) typical of std::set. These should be called sparingly in
+ // performance-critical code.
+ const_iterator FindSize(size_t size) const { return Find(ValueType(size)); }
+ const_iterator FindCallStack(const CallStack* call_stack) const {
+ return Find(ValueType(call_stack));
+ }
+
private:
+ // Returns an iterator to the element in |entries_| with value=|value|, or to
+ // entries_.end() if it was not found.
+ const_iterator Find(const ValueType& value) const;
+
// Max and min counts. Returns 0 if the list is empty.
int max_count() const {
return entries_.empty() ? 0 : entries_.begin()->count;
« no previous file with comments | « components/metrics/leak_detector/leak_detector_impl_unittest.cc ('k') | components/metrics/leak_detector/ranked_set.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698