Index: base/values.cc |
diff --git a/base/values.cc b/base/values.cc |
index 5cc0d693bdd11c12e60f14f8921bec3cd303e4da..477d38291177b1537ae793cfbf3a1b287055455e 100644 |
--- a/base/values.cc |
+++ b/base/values.cc |
@@ -173,26 +173,24 @@ 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)); |
- } |
+ if (type_ == that.type_) { |
+ DCHECK(this != &that) << " attempt to self move assign."; |
+ InternalMoveAssignFromSameType(std::move(that)); |
dcheng
2017/03/10 18:40:15
We should just remove the branch entirely if we're
dyaroshev
2017/03/10 18:54:57
Done.
std::variant (http://en.cppreference.com/w/c
|
+ } else { |
+ InternalCleanup(); |
+ InternalMoveConstructFrom(std::move(that)); |
} |
return *this; |