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

Unified Diff: base/memory/scoped_vector.h

Issue 2314833002: Remove some uses of stl_util's STLDeleteContainerPointers. (Closed)
Patch Set: remove more 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
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/ping_manager.h » ('j') | ui/message_center/notification_list.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/scoped_vector.h
diff --git a/base/memory/scoped_vector.h b/base/memory/scoped_vector.h
index ebc2617cfb2f456ad4e0f14c8272c21e2866a4b7..508c37bea32eb6256df948cce04bad2b3c4f22e4 100644
--- a/base/memory/scoped_vector.h
+++ b/base/memory/scoped_vector.h
@@ -88,8 +88,14 @@ class ScopedVector {
// Resize, deleting elements in the disappearing range if we are shrinking.
void resize(size_t new_size) {
- if (v_.size() > new_size)
- base::STLDeleteContainerPointers(v_.begin() + new_size, v_.end());
+ if (v_.size() > new_size) {
+ auto it = v_.begin() + new_size;
+ auto end = v_.end();
+ while (it != end) {
+ delete *it;
+ ++it;
Nico 2016/09/08 17:32:00 how is this better than the old thing?
Avi (use Gerrit) 2016/09/13 14:36:13 I'm trying to remove STLDeleteContainerPointers, a
+ }
+ }
v_.resize(new_size);
}
@@ -124,7 +130,11 @@ class ScopedVector {
}
iterator erase(iterator first, iterator last) {
- base::STLDeleteContainerPointers(first, last);
+ auto it = first;
+ while (it != last) {
+ delete *it;
+ ++it;
+ }
return v_.erase(first, last);
}
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/ping_manager.h » ('j') | ui/message_center/notification_list.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698