Chromium Code Reviews| Index: src/wasm/wasm-result.h |
| diff --git a/src/wasm/wasm-result.h b/src/wasm/wasm-result.h |
| index e741de8e5e187e8a4fef4053f910128f61235e73..5b6b5671bad20799fe05e86436e8014fed17e702 100644 |
| --- a/src/wasm/wasm-result.h |
| +++ b/src/wasm/wasm-result.h |
| @@ -5,6 +5,8 @@ |
| #ifndef V8_WASM_RESULT_H_ |
| #define V8_WASM_RESULT_H_ |
| +#include <memory> |
| + |
| #include "src/base/compiler-specific.h" |
| #include "src/base/smart-pointers.h" |
| @@ -39,8 +41,12 @@ enum ErrorCode { |
| // The overall result of decoding a function or a module. |
| template <typename T> |
| struct Result { |
| - Result() : val(), error_code(kSuccess), start(nullptr), error_pc(nullptr) { |
| - error_msg.Reset(nullptr); |
| + Result() : val(), error_code(kSuccess), start(nullptr), error_pc(nullptr) {} |
| + Result(Result&& other) { *this = std::move(other); } |
| + Result& operator=(Result&& other) { |
| + MoveFrom(other); |
| + val = other.val; |
| + return *this; |
| } |
| T val; |
| @@ -48,19 +54,22 @@ struct Result { |
| const byte* start; |
| const byte* error_pc; |
| const byte* error_pt; |
| - base::SmartArrayPointer<char> error_msg; |
| + std::unique_ptr<char[]> error_msg; |
| bool ok() const { return error_code == kSuccess; } |
| bool failed() const { return error_code != kSuccess; } |
| template <typename V> |
| - void CopyFrom(Result<V>& that) { |
| + void MoveFrom(Result<V>& that) { |
| error_code = that.error_code; |
| start = that.start; |
| error_pc = that.error_pc; |
| error_pt = that.error_pt; |
| - error_msg = that.error_msg; |
| + error_msg.swap(that.error_msg); |
|
Igor Sheludko
2016/07/25 09:37:32
Since "that" is probably going to live for a while
jochen (gone - plz use gerrit)
2016/07/25 10:35:08
done
|
| } |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(Result); |
| }; |
| template <typename T> |