diff --git a/cpp/include/Ice/InputStream.h b/cpp/include/Ice/InputStream.h index 7524ae9b474..323bbcb918a 100644 --- a/cpp/include/Ice/InputStream.h +++ b/cpp/include/Ice/InputStream.h @@ -176,6 +176,18 @@ namespace Ice InputStream(const CommunicatorPtr&, const EncodingVersion&, IceInternal::Buffer&, bool = false); /// \endcond + /** + * Move constructor. + * @param other The input stream to move into this input stream. + */ + InputStream(InputStream&& other) noexcept; + + /** + * Move assignment operator. + * @param other The input stream to move into this input stream. + */ + InputStream& operator=(InputStream&& other) noexcept; + ~InputStream() { // Inlined for performance reasons. diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index 52ee7a6d1b5..6c782b1bf50 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -3164,7 +3164,7 @@ Ice::ConnectionI::parseMessage(int32_t& upcallCount, functiongetIs()); + *outAsync->getIs() = std::move(stream); #if defined(ICE_USE_IOCP) // diff --git a/cpp/src/Ice/InputStream.cpp b/cpp/src/Ice/InputStream.cpp index 6f25a36a2a8..63aab1ba3d2 100644 --- a/cpp/src/Ice/InputStream.cpp +++ b/cpp/src/Ice/InputStream.cpp @@ -127,6 +127,54 @@ Ice::InputStream::InputStream(Instance* instance, const EncodingVersion& encodin initialize(instance, encoding); } +Ice::InputStream::InputStream(InputStream&& other) noexcept + : Buffer(std::move(other)), + _instance(other._instance), + _encoding(std::move(other._encoding)), + _traceSlicing(other._traceSlicing), + _classGraphDepthMax(other._classGraphDepthMax), + _closure(other._closure), + _sliceValues(other._sliceValues), + _startSeq(other._startSeq), + _minSeqSize(other._minSeqSize), + _valueFactoryManager(std::move(other._valueFactoryManager)), + _logger(std::move(other._logger)), + _compactIdResolver(std::move(other._compactIdResolver)) +{ + resetEncapsulation(); + + // Reset other to its default state + other.resetEncapsulation(); + other.initialize(currentEncoding); +} + +InputStream& +Ice::InputStream::operator=(InputStream&& other) noexcept +{ + if (this != &other) + { + Buffer::operator=(std::move(other)); + _instance = other._instance; + _encoding = std::move(other._encoding); + _traceSlicing = other._traceSlicing; + _classGraphDepthMax = other._classGraphDepthMax; + _closure = other._closure; + _sliceValues = other._sliceValues; + _startSeq = other._startSeq; + _minSeqSize = other._minSeqSize; + _valueFactoryManager = std::move(other._valueFactoryManager); + _logger = std::move(other._logger); + _compactIdResolver = std::move(other._compactIdResolver); + + resetEncapsulation(); + + // Reset other to its default state. + other.resetEncapsulation(); + other.initialize(currentEncoding); + } + return *this; +} + void Ice::InputStream::initialize(const CommunicatorPtr& communicator) { @@ -153,12 +201,12 @@ Ice::InputStream::initialize(Instance* instance, const EncodingVersion& encoding void Ice::InputStream::initialize(const EncodingVersion& encoding) { - _instance = 0; + _instance = nullptr; _encoding = encoding; - _currentEncaps = 0; + _currentEncaps = nullptr; _traceSlicing = false; _classGraphDepthMax = 0x7fffffff; - _closure = 0; + _closure = nullptr; _sliceValues = true; _startSeq = -1; _minSeqSize = 0;