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

Side by Side Diff: components/metrics/leak_detector/ranked_set.cc

Issue 1878863004: Revert of Record call site history in LeakDetectorImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/metrics/leak_detector/ranked_set.h" 5 #include "components/metrics/leak_detector/ranked_set.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 namespace metrics { 9 namespace metrics {
10 namespace leak_detector { 10 namespace leak_detector {
(...skipping 30 matching lines...) Expand all
41 new_entry.count = count; 41 new_entry.count = count;
42 entries_.insert(new_entry); 42 entries_.insert(new_entry);
43 43
44 // Limit the container size if it exceeds the maximum allowed size, by 44 // Limit the container size if it exceeds the maximum allowed size, by
45 // deleting the last element. This should only iterate once because the size 45 // deleting the last element. This should only iterate once because the size
46 // can only have increased by 1, but use a while loop just to be safe. 46 // can only have increased by 1, but use a while loop just to be safe.
47 while (entries_.size() > max_size_) 47 while (entries_.size() > max_size_)
48 entries_.erase(--entries_.end()); 48 entries_.erase(--entries_.end());
49 } 49 }
50 50
51 RankedSet::const_iterator RankedSet::Find(const ValueType& value) const {
52 // The entries are stored sorted by |count|, but this function looks for an
53 // entry with a particular |value| field. Thus, std::set::find() will not
54 // work. Nor would std::find(), which matches by both |count| and |value| --
55 // the count is unknown to the caller of this function.
56 //
57 // The most straightforward way is to iterate through the set until a matching
58 // value is found.
59 for (const_iterator iter = begin(); iter != end(); ++iter) {
60 if (iter->value == value)
61 return iter;
62 }
63 return end();
64 }
65
66 } // namespace leak_detector 51 } // namespace leak_detector
67 } // namespace metrics 52 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/leak_detector/ranked_set.h ('k') | components/metrics/leak_detector/ranked_set_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698