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

Unified Diff: base/values.cc

Issue 2336863003: Change more base::ListValue methods to use std::unique_ptr. (Closed)
Patch Set: . 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 | « base/values.h ('k') | chrome/browser/chromeos/extensions/users_private/users_private_api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/values.cc
diff --git a/base/values.cc b/base/values.cc
index 060bd996af73296150258a765c9ede04a8440ffd..4d9db78ebba8e6a83e8714e97f8e34a99d46f3c3 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_.push_back(std::move(in_value));
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;
}
« no previous file with comments | « base/values.h ('k') | chrome/browser/chromeos/extensions/users_private/users_private_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698