# HG changeset patch # User Sebastien Jodogne # Date 1559550614 -7200 # Node ID f5467ab24aa41a4b8fb19882bc05355c5720cbc7 # Parent 2b645caab9ee6904f2a9255530566d77c92b4442 ChunkedBuffer::AddChunkDestructive() diff -r 2b645caab9ee -r f5467ab24aa4 Core/ChunkedBuffer.cpp --- a/Core/ChunkedBuffer.cpp Wed May 29 18:12:28 2019 +0200 +++ b/Core/ChunkedBuffer.cpp Mon Jun 03 10:30:14 2019 +0200 @@ -77,6 +77,19 @@ } + void ChunkedBuffer::AddChunkDestructive(std::string& chunk) + { + size_t chunkSize = chunk.size(); + + if (chunkSize > 0) + { + chunks_.push_back(new std::string); + chunks_.back()->swap(chunk); + numBytes_ += chunkSize; + } + } + + void ChunkedBuffer::Flatten(std::string& result) { result.resize(numBytes_); diff -r 2b645caab9ee -r f5467ab24aa4 Core/ChunkedBuffer.h --- a/Core/ChunkedBuffer.h Wed May 29 18:12:28 2019 +0200 +++ b/Core/ChunkedBuffer.h Mon Jun 03 10:30:14 2019 +0200 @@ -67,6 +67,9 @@ void AddChunk(const std::string& chunk); + // The source content will be emptied + void AddChunkDestructive(std::string& chunk); + void Flatten(std::string& result); }; }