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

Unified Diff: base/memory/scoped_vector.h

Issue 2463603002: Remove the use of STLDeleteContainerPointers from ScopedVector. (Closed)
Patch Set: reparent Created 4 years, 1 month 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/sync_file_system/drive_backend/metadata_database_index.cc » ('j') | no next file with comments »
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..a320b1e5d1f0668f06dae7d8b40913e21939cac7 100644
--- a/base/memory/scoped_vector.h
+++ b/base/memory/scoped_vector.h
@@ -12,7 +12,6 @@
#include "base/logging.h"
#include "base/macros.h"
-#include "base/stl_util.h"
// ScopedVector wraps a vector deleting the elements from its
// destructor.
@@ -88,8 +87,10 @@ 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) {
+ for (auto it = v_.begin() + new_size; it != v_.end(); ++it)
+ delete *it;
+ }
v_.resize(new_size);
}
@@ -98,7 +99,11 @@ class ScopedVector {
v_.assign(begin, end);
}
- void clear() { base::STLDeleteElements(&v_); }
+ void clear() {
+ for (auto* item : *this)
+ delete item;
+ v_.clear();
+ }
// Like |clear()|, but doesn't delete any elements.
void weak_clear() { v_.clear(); }
@@ -124,7 +129,8 @@ class ScopedVector {
}
iterator erase(iterator first, iterator last) {
- base::STLDeleteContainerPointers(first, last);
+ for (auto it = first; it != last; ++it)
+ delete *it;
return v_.erase(first, last);
}
« no previous file with comments | « no previous file | chrome/browser/sync_file_system/drive_backend/metadata_database_index.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698