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

Unified Diff: base/stl_util.h

Issue 2318303002: Remove stl_util's STLDeleteContainerPairSecondPointers. (Closed)
Patch Set: fix Created 4 years, 3 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: base/stl_util.h
diff --git a/base/stl_util.h b/base/stl_util.h
index b8683377bb7872c711c4bc5bef21a19db87bcf29..4159d8524a3f7e24d7d9101daae9d2d27b1d99a3 100644
--- a/base/stl_util.h
+++ b/base/stl_util.h
@@ -47,20 +47,6 @@ void STLDeleteContainerPointers(ForwardIterator begin, ForwardIterator end) {
}
}
-// For a range within a container of pairs, calls delete.
-// NOTE: Like STLDeleteContainerPointers, deleting behind the iterator.
-// Deleting the value does not always invalidate the iterator, but it may
-// do so if the key is a pointer into the value object.
-template <class ForwardIterator>
-void STLDeleteContainerPairSecondPointers(ForwardIterator begin,
- ForwardIterator end) {
- while (begin != end) {
- ForwardIterator temp = begin;
- ++begin;
- delete temp->second;
- }
-}
Nico 2016/09/22 15:56:11 The usual comment: I"d put this bit in a separate
Avi (use Gerrit) 2016/09/22 19:17:16 Done.
-
// Counts the number of instances of val in a container.
template <typename Container, typename T>
typename std::iterator_traits<
@@ -110,7 +96,14 @@ template <class T>
void STLDeleteValues(T* container) {
if (!container)
return;
- STLDeleteContainerPairSecondPointers(container->begin(), container->end());
+
+ auto it = container->begin();
+ while (it != container->end()) {
+ auto temp = it;
+ ++it;
+ delete temp->second;
+ }
+
container->clear();
}
« no previous file with comments | « no previous file | chrome/browser/app_controller_mac.h » ('j') | chrome/browser/browsing_data/browsing_data_cookie_helper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698