diff options
author | Mathias Stearn <mathias@10gen.com> | 2012-12-06 13:23:14 -0500 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2012-12-10 18:54:05 -0500 |
commit | 6b1a5fd8b0814240591b8b3e78c3749f6acec23c (patch) | |
tree | 3d486922edf77237c6420f4a9b517ef662460916 /src/mongo/db/pipeline/document.h | |
parent | cb7bd2463a04d9e5716c55584b19d3d8acb8a6c4 (diff) | |
download | mongo-6b1a5fd8b0814240591b8b3e78c3749f6acec23c.tar.gz |
Optimize MutableDocument::freeze
Diffstat (limited to 'src/mongo/db/pipeline/document.h')
-rw-r--r-- | src/mongo/db/pipeline/document.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/mongo/db/pipeline/document.h b/src/mongo/db/pipeline/document.h index bfae94badd9..4de1f113888 100644 --- a/src/mongo/db/pipeline/document.h +++ b/src/mongo/db/pipeline/document.h @@ -298,8 +298,11 @@ namespace mongo { * TODO: there are some optimizations that may make sense at freeze time. */ Document freeze() { - Document ret(storagePtr()); - reset(NULL); + // This essentially moves _storage into a new Document by way of temp. + Document ret; + intrusive_ptr<const DocumentStorage> temp (storagePtr(), /*inc_ref_count=*/false); + temp.swap(ret._storage); + _storage = NULL; return ret; } |