diff options
author | Adam Midvidy <amidvidy@gmail.com> | 2015-11-12 00:37:49 -0500 |
---|---|---|
committer | Adam Midvidy <amidvidy@gmail.com> | 2015-11-13 10:50:32 -0500 |
commit | 289d3fdf5c9d5b232b383c6cd871de1b75cf76b4 (patch) | |
tree | 58bcb98e92fb61e805674afbfb6db775959889dd /src/mongo/rpc/legacy_reply.cpp | |
parent | d7511a9244ecab9ea894bb4e8767a289314a1e34 (diff) | |
download | mongo-289d3fdf5c9d5b232b383c6cd871de1b75cf76b4.tar.gz |
SERVER-20884 build command replies in-place to avoid copies
Diffstat (limited to 'src/mongo/rpc/legacy_reply.cpp')
-rw-r--r-- | src/mongo/rpc/legacy_reply.cpp | 22 |
1 files changed, 1 insertions, 21 deletions
diff --git a/src/mongo/rpc/legacy_reply.cpp b/src/mongo/rpc/legacy_reply.cpp index 60d68008558..e298a97814f 100644 --- a/src/mongo/rpc/legacy_reply.cpp +++ b/src/mongo/rpc/legacy_reply.cpp @@ -67,27 +67,7 @@ LegacyReply::LegacyReply(const Message* message) : _message(std::move(message)) std::tie(_commandReply, _metadata) = uassertStatusOK(rpc::upconvertReplyMetadata(BSONObj(qr.data()))); - // Copy the bson array of documents from the message into - // a contiguous area of memory owned by _docBuffer so - // DocumentRange can be used to iterate over documents - auto cursorElem = _commandReply[LegacyReplyBuilder::kCursorTag]; - if (cursorElem.eoo()) - return; - - BSONObj cursorObj = cursorElem.Obj(); - auto firstBatchElem = cursorObj[LegacyReplyBuilder::kFirstBatchTag]; - if (firstBatchElem.eoo()) - return; - - for (BSONObjIterator it(firstBatchElem.Obj()); it.more(); it.next()) { - invariant((*it).isABSONObj()); - BSONObj doc = (*it).Obj(); - doc.appendSelfToBufBuilder(_docBuffer); - } - const char* dataBegin = _docBuffer.buf(); - const char* dataEnd = dataBegin + _docBuffer.len(); - _outputDocs = DocumentRange(dataBegin, dataEnd); - + _outputDocs = DocumentRange{}; return; } |