mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mp...@apache.org
Subject mesos git commit: Added `noexcept` specifier to `Option`.
Date Fri, 08 Dec 2017 17:23:57 GMT
Repository: mesos
Updated Branches:
  refs/heads/master 6ddb48e6c -> ed3fcdfbc


Added `noexcept` specifier to `Option`.

`noexcept` on move constructor and move assignment operator allows
the standard library to leverage some optimizations, e.g. `std::vector`
will move elements, when growing, rather than making copies.
Specifically, `mesos::Resources::Resource_` compiler-generated
constructor is deduced as `noexcept` after this change, improving
performance of operations on `mesos::Resources`.

Review: https://reviews.apache.org/r/63951/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ed3fcdfb
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ed3fcdfb
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ed3fcdfb

Branch: refs/heads/master
Commit: ed3fcdfbcda0f2e32860d44b6654829c4952f7e6
Parents: 6ddb48e
Author: Dmitry Zhuk <dzhuk@twopensource.com>
Authored: Fri Dec 8 08:58:35 2017 -0800
Committer: Michael Park <mpark@apache.org>
Committed: Fri Dec 8 09:23:48 2017 -0800

----------------------------------------------------------------------
 3rdparty/stout/include/stout/option.hpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ed3fcdfb/3rdparty/stout/include/stout/option.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/option.hpp b/3rdparty/stout/include/stout/option.hpp
index 32133f9..72403e7 100644
--- a/3rdparty/stout/include/stout/option.hpp
+++ b/3rdparty/stout/include/stout/option.hpp
@@ -17,6 +17,7 @@
 
 #include <algorithm>
 #include <functional>
+#include <type_traits>
 
 #include <boost/functional/hash.hpp>
 
@@ -64,7 +65,9 @@ public:
     }
   }
 
-  Option(Option<T>&& that) : state(std::move(that.state))
+  Option(Option<T>&& that)
+      noexcept(std::is_nothrow_move_constructible<T>::value)
+    : state(std::move(that.state))
   {
     if (that.isSome()) {
       new (&t) T(std::move(that.t));
@@ -94,6 +97,7 @@ public:
   }
 
   Option<T>& operator=(Option<T>&& that)
+      noexcept(std::is_nothrow_move_constructible<T>::value)
   {
     if (this != &that) {
       if (isSome()) {


Mime
View raw message