diff options
Diffstat (limited to 'src/mongo/db/pipeline/document_source_out.cpp')
-rw-r--r-- | src/mongo/db/pipeline/document_source_out.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mongo/db/pipeline/document_source_out.cpp b/src/mongo/db/pipeline/document_source_out.cpp index cefaaefcf4b..9d830162109 100644 --- a/src/mongo/db/pipeline/document_source_out.cpp +++ b/src/mongo/db/pipeline/document_source_out.cpp @@ -202,14 +202,16 @@ DocumentSource::GetNextResult DocumentSourceOut::getNext() { bufferedBytes += insertObj.objsize(); if (!batch.empty() && (bufferedBytes > BSONObjMaxUserSize || batch.size() >= write_ops::kMaxWriteBatchSize)) { - spill(batch); + spill(std::move(batch)); batch.clear(); bufferedBytes = insertObj.objsize(); } batch.emplace(std::move(insertObj), std::move(uniqueKey)); } - if (!batch.empty()) - spill(batch); + if (!batch.empty()) { + spill(std::move(batch)); + batch.clear(); + } switch (nextInput.getStatus()) { case GetNextResult::ReturnStatus::kAdvanced: { |