diff options
author | Martin Neupauer <martin.neupauer@mongodb.com> | 2019-09-26 16:36:11 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-09-26 16:36:11 +0000 |
commit | 68a820251e7a7fbd61357d9698a3de5e34007559 (patch) | |
tree | 05985fe5ea99b9ded8a22ab14d46f2e7ae7110ef /src/mongo/db/pipeline/document_internal.h | |
parent | 7f744d70a9b4ded9a45b7f1b8d29bfa0f4d0e50f (diff) | |
download | mongo-68a820251e7a7fbd61357d9698a3de5e34007559.tar.gz |
SERVER-43629 Improve Document/Value performance
Diffstat (limited to 'src/mongo/db/pipeline/document_internal.h')
-rw-r--r-- | src/mongo/db/pipeline/document_internal.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/mongo/db/pipeline/document_internal.h b/src/mongo/db/pipeline/document_internal.h index d521fa5aec7..b76feefc8e0 100644 --- a/src/mongo/db/pipeline/document_internal.h +++ b/src/mongo/db/pipeline/document_internal.h @@ -265,10 +265,8 @@ private: /// Storage class used by both Document and MutableDocument class DocumentStorage : public RefCountable { public: - DocumentStorage() : DocumentStorage(BSONObj(), false, false) { - // Aggregation assumes ownership of underlying BSON even if it is empty. - makeOwned(); - } + DocumentStorage() : DocumentStorage(BSONObj(), false, false) {} + /** * Construct a storage from the BSON. The BSON is lazily processed as fields are requested from * the document. If we know that the BSON does not contain any metadata fields we can set the @@ -372,7 +370,9 @@ public: } bool isOwned() const { - return _bson.isOwned(); + // An empty BSON is a special case, it can be treated 'owned'. We save on memory allocation + // when constructing an empty Document. + return _bson.isEmpty() || _bson.isOwned(); } void makeOwned() { |