diff options
author | Tyler Brock <tyler.brock@gmail.com> | 2014-07-14 11:57:29 -0400 |
---|---|---|
committer | Tyler Brock <tyler.brock@gmail.com> | 2014-07-16 11:21:22 -0400 |
commit | d134ba27aa7f2c4eb8fc4b1331c8331f5914bfc6 (patch) | |
tree | bdf12b196a8b3c46fb748f988de088c14f5294ff /src/mongo/bson/mutable/document.cpp | |
parent | 804423e1b6436096576e9476c42e4f68c77e0535 (diff) | |
download | mongo-d134ba27aa7f2c4eb8fc4b1331c8331f5914bfc6.tar.gz |
SERVER-14482 Add add missing appendX methods to BSONArrayBuilder
Diffstat (limited to 'src/mongo/bson/mutable/document.cpp')
-rw-r--r-- | src/mongo/bson/mutable/document.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/mongo/bson/mutable/document.cpp b/src/mongo/bson/mutable/document.cpp index 5057ab2d69a..e3eccfb18c7 100644 --- a/src/mongo/bson/mutable/document.cpp +++ b/src/mongo/bson/mutable/document.cpp @@ -2102,6 +2102,23 @@ namespace mutablebson { BufBuilder& buffer; }; + static void appendElement(BSONObjBuilder* builder, + const BSONElement& element, + const StringData* fieldName) { + if (fieldName) + builder->appendAs(element, *fieldName); + else + builder->append(element); + } + + // BSONArrayBuilder should not be appending elements with a fieldName + static void appendElement(BSONArrayBuilder* builder, + const BSONElement& element, + const StringData* fieldName) { + invariant(!fieldName); + builder->append(element); + } + } // namespace template<typename Builder> @@ -2111,11 +2128,7 @@ namespace mutablebson { const ElementRep& rep = getElementRep(repIdx); if (hasValue(rep)) { - const BSONElement element = getSerializedElement(rep); - if (fieldName) - builder->appendAs(element, *fieldName); - else - builder->append(element); + appendElement(builder, getSerializedElement(rep), fieldName); } else { const BSONType type = getType(rep); const StringData subName = fieldName ? *fieldName : getFieldName(rep); |