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

Unified Diff: base/values.cc

Issue 2336863003: Change more base::ListValue methods to use std::unique_ptr. (Closed)
Patch Set: Header 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/values.cc
diff --git a/base/values.cc b/base/values.cc
index 060bd996af73296150258a765c9ede04a8440ffd..b68346e9bcbb44dcff23126f1e00b86163e31d61 100644
--- a/base/values.cc
+++ b/base/values.cc
@@ -1081,24 +1081,23 @@ void ListValue::AppendStrings(const std::vector<string16>& in_values) {
}
}
-bool ListValue::AppendIfNotPresent(Value* in_value) {
+bool ListValue::AppendIfNotPresent(std::unique_ptr<Value> in_value) {
DCHECK(in_value);
for (const auto& entry : list_) {
- if (entry->Equals(in_value)) {
- delete in_value;
+ if (entry->Equals(in_value.get())) {
return false;
}
}
- list_.emplace_back(in_value);
+ list_.emplace_back(std::move(in_value));
danakj 2016/09/13 23:58:37 push back? you have the type going into the list a
dcheng 2016/09/14 01:16:51 Done.
return true;
}
-bool ListValue::Insert(size_t index, Value* in_value) {
+bool ListValue::Insert(size_t index, std::unique_ptr<Value> in_value) {
DCHECK(in_value);
if (index > list_.size())
return false;
- list_.insert(list_.begin() + index, WrapUnique(in_value));
+ list_.insert(list_.begin() + index, std::move(in_value));
return true;
}

Powered by Google App Engine
This is Rietveld 408576698