From a963a6d10d2fff2d0e8d35d3162f0f1dde4448a6 Mon Sep 17 00:00:00 2001 From: Tom Ritchford Date: Tue, 10 Feb 2015 12:57:29 -0500 Subject: [PATCH] Add noexcept qualifier to swaps and moves. --- src/ripple/app/tx/TransactionMeta.cpp | 2 +- src/ripple/app/tx/TransactionMeta.h | 2 +- src/ripple/json/impl/json_internalmap.inl | 2 +- src/ripple/json/impl/json_value.cpp | 8 ++++---- src/ripple/json/json_value.h | 12 ++++++------ src/ripple/protocol/STArray.h | 2 +- src/ripple/rpc/impl/JsonObject.cpp | 4 ++-- src/ripple/rpc/impl/JsonObject.h | 6 +++--- src/ripple/rpc/impl/JsonWriter.cpp | 4 ++-- src/ripple/rpc/impl/JsonWriter.h | 4 ++-- src/ripple/websocket/autosocket/AutoSocket.h | 2 +- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/ripple/app/tx/TransactionMeta.cpp b/src/ripple/app/tx/TransactionMeta.cpp index 22d4e644d6..a3800a4e1d 100644 --- a/src/ripple/app/tx/TransactionMeta.cpp +++ b/src/ripple/app/tx/TransactionMeta.cpp @@ -194,7 +194,7 @@ void TransactionMetaSet::init (uint256 const& id, std::uint32_t ledger) mDelivered = boost::optional (); } -void TransactionMetaSet::swap (TransactionMetaSet& s) +void TransactionMetaSet::swap (TransactionMetaSet& s) noexcept { assert ((mTransactionID == s.mTransactionID) && (mLedger == s.mLedger)); mNodes.swap (s.mNodes); diff --git a/src/ripple/app/tx/TransactionMeta.h b/src/ripple/app/tx/TransactionMeta.h index 1a1381d6d3..b0e75c10b2 100644 --- a/src/ripple/app/tx/TransactionMeta.h +++ b/src/ripple/app/tx/TransactionMeta.h @@ -56,7 +56,7 @@ public: { mNodes.clear (); } - void swap (TransactionMetaSet&); + void swap (TransactionMetaSet&) noexcept; uint256 const& getTxID () { diff --git a/src/ripple/json/impl/json_internalmap.inl b/src/ripple/json/impl/json_internalmap.inl index 31f66688d0..94b693dd3b 100644 --- a/src/ripple/json/impl/json_internalmap.inl +++ b/src/ripple/json/impl/json_internalmap.inl @@ -241,7 +241,7 @@ ValueInternalMap::~ValueInternalMap () void -ValueInternalMap::swap ( ValueInternalMap& other ) +ValueInternalMap::swap ( ValueInternalMap& other ) noexcept { ValueInternalLink* tempBuckets = buckets_; buckets_ = other.buckets_; diff --git a/src/ripple/json/impl/json_value.cpp b/src/ripple/json/impl/json_value.cpp index c8e3ad0cdf..bb6e108d9c 100644 --- a/src/ripple/json/impl/json_value.cpp +++ b/src/ripple/json/impl/json_value.cpp @@ -208,7 +208,7 @@ Value::CZString::~CZString () } void -Value::CZString::swap ( CZString& other ) +Value::CZString::swap ( CZString& other ) noexcept { std::swap ( cstr_, other.cstr_ ); std::swap ( index_, other.index_ ); @@ -558,7 +558,7 @@ Value::operator= ( const Value& other ) return *this; } -Value::Value ( Value&& other ) +Value::Value ( Value&& other ) noexcept : value_ ( other.value_ ) , type_ ( other.type_ ) , allocated_ ( other.allocated_ ) @@ -572,14 +572,14 @@ Value::Value ( Value&& other ) } Value& -Value::operator= ( Value&& other ) +Value::operator= ( Value&& other ) noexcept { swap ( other ); return *this; } void -Value::swap ( Value& other ) +Value::swap ( Value& other ) noexcept { std::swap ( value_, other.value_ ); diff --git a/src/ripple/json/json_value.h b/src/ripple/json/json_value.h index 1b9d807d53..372bc36b97 100644 --- a/src/ripple/json/json_value.h +++ b/src/ripple/json/json_value.h @@ -165,7 +165,7 @@ private: const char* c_str () const; bool isStaticString () const; private: - void swap ( CZString& other ); + void swap ( CZString& other ) noexcept; const char* cstr_; int index_; }; @@ -224,13 +224,13 @@ public: Value& operator= ( const Value& other ); - Value ( Value&& other ); - Value& operator= ( Value&& other ); + Value ( Value&& other ) noexcept; + Value& operator= ( Value&& other ) noexcept; /// Swap values. /// \note Currently, comments are intentionally not swapped, for /// both logic and efficiency. - void swap ( Value& other ); + void swap ( Value& other ) noexcept; ValueType type () const; @@ -678,7 +678,7 @@ public: ValueInternalMap& operator = ( const ValueInternalMap& other ); ~ValueInternalMap (); - void swap ( ValueInternalMap& other ); + void swap ( ValueInternalMap& other ) noexcept; BucketIndex size () const; @@ -774,7 +774,7 @@ public: ValueInternalArray ( const ValueInternalArray& other ); ValueInternalArray& operator = ( const ValueInternalArray& other ); ~ValueInternalArray (); - void swap ( ValueInternalArray& other ); + void swap ( ValueInternalArray& other ) noexcept; void clear (); void resize ( ArrayIndex newSize ); diff --git a/src/ripple/protocol/STArray.h b/src/ripple/protocol/STArray.h index 580e097834..bb333f25d6 100644 --- a/src/ripple/protocol/STArray.h +++ b/src/ripple/protocol/STArray.h @@ -170,7 +170,7 @@ public: { value.clear (); } - void swap (STArray & a) + void swap (STArray & a) noexcept { value.swap (a.value); } diff --git a/src/ripple/rpc/impl/JsonObject.cpp b/src/ripple/rpc/impl/JsonObject.cpp index 778778a6a3..8a5bcc3ebc 100644 --- a/src/ripple/rpc/impl/JsonObject.cpp +++ b/src/ripple/rpc/impl/JsonObject.cpp @@ -42,7 +42,7 @@ Collection::~Collection () parent_->enabled_ = true; } -Collection& Collection::operator= (Collection&& that) +Collection& Collection::operator= (Collection&& that) noexcept { parent_ = that.parent_; writer_ = that.writer_; @@ -55,7 +55,7 @@ Collection& Collection::operator= (Collection&& that) return *this; } -Collection::Collection (Collection&& that) +Collection::Collection (Collection&& that) noexcept { *this = std::move (that); } diff --git a/src/ripple/rpc/impl/JsonObject.h b/src/ripple/rpc/impl/JsonObject.h index 977350eb19..592d0027fc 100644 --- a/src/ripple/rpc/impl/JsonObject.h +++ b/src/ripple/rpc/impl/JsonObject.h @@ -151,8 +151,8 @@ namespace RPC { class Collection { public: - Collection (Collection&& c); - Collection& operator= (Collection&& c); + Collection (Collection&& c) noexcept; + Collection& operator= (Collection&& c) noexcept; Collection() = delete; ~Collection(); @@ -294,7 +294,7 @@ public: } #ifdef _MSC_VER - WriterObject (WriterObject&& other) + WriterObject (WriterObject&& other) noexcept : writer_ (std::move (other.writer_)), object_ (std::move (other.object_)) { diff --git a/src/ripple/rpc/impl/JsonWriter.cpp b/src/ripple/rpc/impl/JsonWriter.cpp index ab73d58745..91ef8cc8fe 100644 --- a/src/ripple/rpc/impl/JsonWriter.cpp +++ b/src/ripple/rpc/impl/JsonWriter.cpp @@ -220,12 +220,12 @@ Writer::~Writer() impl_->finishAll (); } -Writer::Writer(Writer&& w) +Writer::Writer(Writer&& w) noexcept { impl_ = std::move (w.impl_); } -Writer& Writer::operator=(Writer&& w) +Writer& Writer::operator=(Writer&& w) noexcept { impl_ = std::move (w.impl_); return *this; diff --git a/src/ripple/rpc/impl/JsonWriter.h b/src/ripple/rpc/impl/JsonWriter.h index e9a8118846..94a1d6d2af 100644 --- a/src/ripple/rpc/impl/JsonWriter.h +++ b/src/ripple/rpc/impl/JsonWriter.h @@ -129,8 +129,8 @@ public: enum CollectionType {array, object}; explicit Writer (Output const& output); - Writer(Writer&&); - Writer& operator=(Writer&&); + Writer(Writer&&) noexcept; + Writer& operator=(Writer&&) noexcept; ~Writer(); diff --git a/src/ripple/websocket/autosocket/AutoSocket.h b/src/ripple/websocket/autosocket/AutoSocket.h index decff24cd5..5033e6b883 100644 --- a/src/ripple/websocket/autosocket/AutoSocket.h +++ b/src/ripple/websocket/autosocket/AutoSocket.h @@ -105,7 +105,7 @@ public: return mSocket->lowest_layer (); } - void swap (AutoSocket& s) + void swap (AutoSocket& s) noexcept { mBuffer.swap (s.mBuffer); mSocket.swap (s.mSocket);