summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/bson/bsonobjbuilder.cpp2
-rw-r--r--src/mongo/bson/util/builder.h7
-rw-r--r--src/mongo/db/index/index_build_interceptor.cpp4
3 files changed, 7 insertions, 6 deletions
diff --git a/src/mongo/bson/bsonobjbuilder.cpp b/src/mongo/bson/bsonobjbuilder.cpp
index 3b8c3774c6b..aaa8b2fafcc 100644
--- a/src/mongo/bson/bsonobjbuilder.cpp
+++ b/src/mongo/bson/bsonobjbuilder.cpp
@@ -230,7 +230,7 @@ BSONObjBuilder::~BSONObjBuilder() {
// BufBuilder but do not own it ourselves, then we must call _done to write in the
// length. Otherwise, we own this memory and its lifetime ends with us, therefore
// we can elide the write.
- if (!_doneCalled && _b.buf() && _buf.getSize() == 0) {
+ if (!_doneCalled && _b.buf() && _buf.capacity() == 0) {
_done();
}
}
diff --git a/src/mongo/bson/util/builder.h b/src/mongo/bson/util/builder.h
index 64b578faafd..4d66fdee83e 100644
--- a/src/mongo/bson/util/builder.h
+++ b/src/mongo/bson/util/builder.h
@@ -273,15 +273,16 @@ public:
str.copyTo(grow(len), includeEndingNull);
}
- /** @return length of current std::string */
+ /** Returns the length of data in the current buffer */
int len() const {
return l;
}
void setlen(int newLen) {
l = newLen;
}
- /** @return size of the buffer */
- int getSize() const {
+
+ /** Returns the capacity of the buffer */
+ int capacity() const {
return size;
}
diff --git a/src/mongo/db/index/index_build_interceptor.cpp b/src/mongo/db/index/index_build_interceptor.cpp
index d1c2e0d6b5d..5e5568dc6c8 100644
--- a/src/mongo/db/index/index_build_interceptor.cpp
+++ b/src/mongo/db/index/index_build_interceptor.cpp
@@ -406,7 +406,7 @@ Status IndexBuildInterceptor::sideWrite(OperationContext* opCtx,
// from getBuffer().
builder.reset();
keyString.serialize(builder);
- BSONBinData binData(builder.buf(), builder.getSize(), BinDataGeneral);
+ BSONBinData binData(builder.buf(), builder.len(), BinDataGeneral);
toInsert.emplace_back(BSON("op" << (op == Op::kInsert ? "i" : "d") << "key" << binData));
}
@@ -417,7 +417,7 @@ Status IndexBuildInterceptor::sideWrite(OperationContext* opCtx,
for (const auto& keyString : multikeyMetadataKeys) {
builder.reset();
keyString.serialize(builder);
- BSONBinData binData(builder.buf(), builder.getSize(), BinDataGeneral);
+ BSONBinData binData(builder.buf(), builder.len(), BinDataGeneral);
toInsert.emplace_back(BSON("op"
<< "i"
<< "key" << binData));