Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Unified Diff: src/wasm/wasm-result.h

Issue 2173403002: Replace SmartArrayPointer<T> with unique_ptr<T[]> (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | test/cctest/compiler/test-operator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-result.h
diff --git a/src/wasm/wasm-result.h b/src/wasm/wasm-result.h
index e741de8e5e187e8a4fef4053f910128f61235e73..af929a500098e781f2a6e321a1a4cfd5167ab121 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 = std::move(that.error_msg);
}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Result);
};
template <typename T>
« no previous file with comments | « src/wasm/wasm-module.cc ('k') | test/cctest/compiler/test-operator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698