You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2014/03/03 23:51:35 UTC
git commit: Changed Result::get to return a const reference.
Repository: mesos
Updated Branches:
refs/heads/master 3dd6c44b7 -> f8fac30c2
Changed Result::get to return a const reference.
Review: https://reviews.apache.org/r/18434
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f8fac30c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f8fac30c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f8fac30c
Branch: refs/heads/master
Commit: f8fac30c2ce51be7f82fe695a4046140e3be9eac
Parents: 3dd6c44
Author: Dominic Hamon <dh...@twopensource.com>
Authored: Mon Mar 3 14:09:49 2014 -0800
Committer: Benjamin Mahler <bm...@twitter.com>
Committed: Mon Mar 3 14:09:49 2014 -0800
----------------------------------------------------------------------
.../3rdparty/stout/include/stout/result.hpp | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/f8fac30c/3rdparty/libprocess/3rdparty/stout/include/stout/result.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/result.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/result.hpp
index 951a113..3a10379 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/result.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/result.hpp
@@ -71,11 +71,7 @@ public:
Result(const Result<T>& that)
{
state = that.state;
- if (that.t != NULL) {
- t = new T(*that.t);
- } else {
- t = NULL;
- }
+ t = (that.t == NULL ? NULL : new T(*that.t));
message = that.message;
}
@@ -89,11 +85,7 @@ public:
if (this != &that) {
delete t;
state = that.state;
- if (that.t != NULL) {
- t = new T(*that.t);
- } else {
- t = NULL;
- }
+ t = (that.t == NULL ? NULL : new T(*that.t));
message = that.message;
}
@@ -104,8 +96,9 @@ public:
bool isNone() const { return state == NONE; }
bool isError() const { return state == ERROR; }
- T get() const
+ const T& get() const
{
+ // TODO(dhamon): Switch this to fatal() once that calls abort().
if (state != SOME) {
if (state == ERROR) {
std::cerr << "Result::get() but state == ERROR: "
@@ -118,6 +111,7 @@ public:
return *t;
}
+ // TODO(dhamon): Return const std::string& to remove copy.
std::string error() const { assert(state == ERROR); return message; }
private: