| Index: webrtc/base/optional.h
|
| diff --git a/webrtc/base/optional.h b/webrtc/base/optional.h
|
| index b047fabc427871ee9d86fdc3f7ef6397c0f82a46..1bcfd1a8c2fbd00e2a470c1140cc8d57a8b276f4 100644
|
| --- a/webrtc/base/optional.h
|
| +++ b/webrtc/base/optional.h
|
| @@ -132,10 +132,8 @@ class Optional final {
|
| new (&value_) T(m.value_); // T's copy constructor.
|
| has_value_ = true;
|
| }
|
| - } else if (has_value_) {
|
| - value_.~T();
|
| - has_value_ = false;
|
| - PoisonValue();
|
| + } else {
|
| + reset();
|
| }
|
| return *this;
|
| }
|
| @@ -152,10 +150,8 @@ class Optional final {
|
| new (&value_) T(std::move(m.value_)); // T's move constructor.
|
| has_value_ = true;
|
| }
|
| - } else if (has_value_) {
|
| - value_.~T();
|
| - has_value_ = false;
|
| - PoisonValue();
|
| + } else {
|
| + reset();
|
| }
|
| return *this;
|
| }
|
| @@ -188,6 +184,15 @@ class Optional final {
|
| }
|
| }
|
|
|
| + // Destroy any contained value. Has no effect if we have no value.
|
| + void reset() {
|
| + if (!has_value_)
|
| + return;
|
| + value_.~T();
|
| + has_value_ = false;
|
| + PoisonValue();
|
| + }
|
| +
|
| // Conversion to bool to test if we have a value.
|
| explicit operator bool() const { return has_value_; }
|
|
|
|
|