Index: base/values.cc |
diff --git a/base/values.cc b/base/values.cc |
index 768e3f790b4c8b1870f070118e5782640e6ce12a..f5e689f31fd0d0004ee4b00de70eabe76c49b507 100644 |
--- a/base/values.cc |
+++ b/base/values.cc |
@@ -49,7 +49,7 @@ std::unique_ptr<DictionaryValue> CopyDictionaryWithoutEmptyChildren( |
std::unique_ptr<Value> child_copy = CopyWithoutEmptyChildren(it.value()); |
if (child_copy) { |
if (!copy) |
- copy.reset(new DictionaryValue); |
+ copy = MakeUnique<DictionaryValue>(); |
copy->SetWithoutPathExpansion(it.key(), std::move(child_copy)); |
} |
} |
@@ -337,7 +337,7 @@ bool Value::GetAsDictionary(const DictionaryValue** out_value) const { |
} |
Value* Value::DeepCopy() const { |
- return new Value(*this); |
+ return CreateDeepCopy().release(); |
jdoerrie
2017/05/08 22:44:47
I'd rather like for this to stay the same. As the
Lei Zhang
2017/05/08 22:58:30
Done.
|
} |
std::unique_ptr<Value> Value::CreateDeepCopy() const { |
@@ -624,9 +624,10 @@ Value* DictionaryValue::Set(StringPiece path, std::unique_ptr<Value> in_value) { |
StringPiece key = current_path.substr(0, delimiter_position); |
DictionaryValue* child_dictionary = nullptr; |
if (!current_dictionary->GetDictionary(key, &child_dictionary)) { |
- child_dictionary = new DictionaryValue; |
+ auto new_child_dictionary = MakeUnique<DictionaryValue>(); |
+ child_dictionary = new_child_dictionary.get(); |
current_dictionary->SetWithoutPathExpansion( |
- key, base::WrapUnique(child_dictionary)); |
+ key, std::move(new_child_dictionary)); |
jdoerrie
2017/05/08 22:44:47
Consider using the recently added SetDictionaryWit
Lei Zhang
2017/05/08 22:58:30
Done. Thanks.
|
} |
current_dictionary = child_dictionary; |
@@ -642,23 +643,23 @@ Value* DictionaryValue::Set(StringPiece path, Value* in_value) { |
} |
Value* DictionaryValue::SetBoolean(StringPiece path, bool in_value) { |
- return Set(path, new Value(in_value)); |
+ return Set(path, MakeUnique<Value>(in_value)); |
} |
Value* DictionaryValue::SetInteger(StringPiece path, int in_value) { |
- return Set(path, new Value(in_value)); |
+ return Set(path, MakeUnique<Value>(in_value)); |
} |
Value* DictionaryValue::SetDouble(StringPiece path, double in_value) { |
- return Set(path, new Value(in_value)); |
+ return Set(path, MakeUnique<Value>(in_value)); |
} |
Value* DictionaryValue::SetString(StringPiece path, StringPiece in_value) { |
- return Set(path, new Value(in_value)); |
+ return Set(path, MakeUnique<Value>(in_value)); |
} |
Value* DictionaryValue::SetString(StringPiece path, const string16& in_value) { |
- return Set(path, new Value(in_value)); |
+ return Set(path, MakeUnique<Value>(in_value)); |
} |
DictionaryValue* DictionaryValue::SetDictionary( |
@@ -685,28 +686,28 @@ Value* DictionaryValue::SetWithoutPathExpansion(StringPiece key, |
Value* DictionaryValue::SetBooleanWithoutPathExpansion(StringPiece path, |
bool in_value) { |
- return SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value)); |
+ return SetWithoutPathExpansion(path, MakeUnique<Value>(in_value)); |
} |
Value* DictionaryValue::SetIntegerWithoutPathExpansion(StringPiece path, |
int in_value) { |
- return SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value)); |
+ return SetWithoutPathExpansion(path, MakeUnique<Value>(in_value)); |
} |
Value* DictionaryValue::SetDoubleWithoutPathExpansion(StringPiece path, |
double in_value) { |
- return SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value)); |
+ return SetWithoutPathExpansion(path, MakeUnique<Value>(in_value)); |
} |
Value* DictionaryValue::SetStringWithoutPathExpansion(StringPiece path, |
StringPiece in_value) { |
- return SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value)); |
+ return SetWithoutPathExpansion(path, MakeUnique<Value>(in_value)); |
} |
Value* DictionaryValue::SetStringWithoutPathExpansion( |
StringPiece path, |
const string16& in_value) { |
- return SetWithoutPathExpansion(path, base::MakeUnique<base::Value>(in_value)); |
+ return SetWithoutPathExpansion(path, MakeUnique<Value>(in_value)); |
} |
DictionaryValue* DictionaryValue::SetDictionaryWithoutPathExpansion( |
@@ -1030,7 +1031,7 @@ std::unique_ptr<DictionaryValue> DictionaryValue::DeepCopyWithoutEmptyChildren() |
std::unique_ptr<DictionaryValue> copy = |
CopyDictionaryWithoutEmptyChildren(*this); |
if (!copy) |
- copy.reset(new DictionaryValue); |
+ copy = MakeUnique<DictionaryValue>(); |
return copy; |
} |
@@ -1065,7 +1066,7 @@ DictionaryValue::Iterator::Iterator(const Iterator& other) = default; |
DictionaryValue::Iterator::~Iterator() {} |
DictionaryValue* DictionaryValue::DeepCopy() const { |
- return new DictionaryValue(*this); |
+ return CreateDeepCopy().release(); |
jdoerrie
2017/05/08 22:44:47
Same here.
Lei Zhang
2017/05/08 22:58:30
Done.
|
} |
std::unique_ptr<DictionaryValue> DictionaryValue::CreateDeepCopy() const { |
@@ -1316,7 +1317,7 @@ void ListValue::Swap(ListValue* other) { |
} |
ListValue* ListValue::DeepCopy() const { |
- return new ListValue(*this); |
+ return CreateDeepCopy().release(); |
jdoerrie
2017/05/08 22:44:48
And here.
Lei Zhang
2017/05/08 22:58:30
Done.
|
} |
std::unique_ptr<ListValue> ListValue::CreateDeepCopy() const { |