| Index: base/values.cc
|
| diff --git a/base/values.cc b/base/values.cc
|
| index 25a25fba6e489ce8420954941598dace98da8f38..6728e55519a77e42ab73c587a0d5b2ff8bd83e95 100644
|
| --- a/base/values.cc
|
| +++ b/base/values.cc
|
| @@ -173,27 +173,21 @@ Value::Value(std::vector<char>&& in_blob) : type_(Type::BINARY) {
|
| }
|
|
|
| Value& Value::operator=(const Value& that) {
|
| - if (this != &that) {
|
| - if (type_ == that.type_) {
|
| - InternalCopyAssignFromSameType(that);
|
| - } else {
|
| - InternalCleanup();
|
| - InternalCopyConstructFrom(that);
|
| - }
|
| + if (type_ == that.type_) {
|
| + InternalCopyAssignFromSameType(that);
|
| + } else {
|
| + // This is not a self assignment because the type_ doesn't match.
|
| + InternalCleanup();
|
| + InternalCopyConstructFrom(that);
|
| }
|
|
|
| return *this;
|
| }
|
|
|
| Value& Value::operator=(Value&& that) {
|
| - if (this != &that) {
|
| - if (type_ == that.type_) {
|
| - InternalMoveAssignFromSameType(std::move(that));
|
| - } else {
|
| - InternalCleanup();
|
| - InternalMoveConstructFrom(std::move(that));
|
| - }
|
| - }
|
| + DCHECK(this != &that) << "attempt to self move assign.";
|
| + InternalCleanup();
|
| + InternalMoveConstructFrom(std::move(that));
|
|
|
| return *this;
|
| }
|
| @@ -534,6 +528,8 @@ void Value::InternalMoveConstructFrom(Value&& that) {
|
| }
|
|
|
| void Value::InternalCopyAssignFromSameType(const Value& that) {
|
| + // TODO(crbug.com/646113): make this a DCHECK once base::Value does not have
|
| + // subclasses.
|
| CHECK_EQ(type_, that.type_);
|
|
|
| switch (type_) {
|
| @@ -563,32 +559,6 @@ void Value::InternalCopyAssignFromSameType(const Value& that) {
|
| }
|
| }
|
|
|
| -void Value::InternalMoveAssignFromSameType(Value&& that) {
|
| - CHECK_EQ(type_, that.type_);
|
| -
|
| - switch (type_) {
|
| - case Type::NONE:
|
| - case Type::BOOLEAN:
|
| - case Type::INTEGER:
|
| - case Type::DOUBLE:
|
| - InternalCopyFundamentalValue(that);
|
| - return;
|
| -
|
| - case Type::STRING:
|
| - *string_value_ = std::move(*that.string_value_);
|
| - return;
|
| - case Type::BINARY:
|
| - *binary_value_ = std::move(*that.binary_value_);
|
| - return;
|
| - case Type::DICTIONARY:
|
| - *dict_ptr_ = std::move(*that.dict_ptr_);
|
| - return;
|
| - case Type::LIST:
|
| - *list_ = std::move(*that.list_);
|
| - return;
|
| - }
|
| -}
|
| -
|
| void Value::InternalCleanup() {
|
| CHECK(alive_);
|
|
|
|
|