diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
| commit | 4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch) | |
| tree | 1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/bson/bsonelement.cpp | |
| parent | aa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff) | |
| parent | 8f0827553e09872941945a093b647a4211a9db7f (diff) | |
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0'
with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'src/mongo/bson/bsonelement.cpp')
| -rw-r--r-- | src/mongo/bson/bsonelement.cpp | 42 |
1 files changed, 5 insertions, 37 deletions
diff --git a/src/mongo/bson/bsonelement.cpp b/src/mongo/bson/bsonelement.cpp index ccfb0fd54e5..430b259699b 100644 --- a/src/mongo/bson/bsonelement.cpp +++ b/src/mongo/bson/bsonelement.cpp @@ -46,7 +46,6 @@ #include "mongo/logv2/log.h" #include "mongo/platform/strnlen.h" #include "mongo/util/base64.h" -#include "mongo/util/decimal_counter.h" #include "mongo/util/duration.h" #include "mongo/util/hex.h" #include "mongo/util/scopeguard.h" @@ -445,7 +444,6 @@ int BSONElement::compareElements(const BSONElement& l, */ std::vector<BSONElement> BSONElement::Array() const { chk(mongo::Array); - std::vector<BSONElement> v; BSONObjIterator i(Obj()); while (i.more()) { @@ -466,23 +464,6 @@ std::vector<BSONElement> BSONElement::Array() const { return v; } -std::vector<BSONElement> BSONElement::ArrayVerifyIndexes() const { - chk(mongo::Array); - - std::vector<BSONElement> v; - DecimalCounter<std::uint32_t> counter(0); - for (auto element : Obj()) { - auto fieldName = element.fieldNameStringData(); - uassert(ErrorCodes::BadValue, - fmt::format( - "Invalid array index field name: \"{}\", expected \"{}\"", fieldName, counter), - fieldName == counter); - counter++; - v.push_back(element); - } - return v; -} - int BSONElement::woCompare(const BSONElement& elem, ComparisonRulesSet rules, const StringData::ComparatorInterface* comparator) const { @@ -702,7 +683,7 @@ MONGO_COMPILER_NOINLINE void msgAssertedBadType [[noreturn]] (const char* data) } } // namespace -int BSONElement::computeSize(int8_t type, const char* elem, int fieldNameSize, int bufSize) { +int BSONElement::computeSize(int8_t type, const char* elem, int fieldNameSize) { enum SizeStyle : uint8_t { kFixed, // Total size is a fixed amount + key length. kIntPlusFixed, // Like Fixed, but also add in the int32 immediately following the key. @@ -774,23 +755,10 @@ int BSONElement::computeSize(int8_t type, const char* elem, int fieldNameSize, i // RegEx is two c-strings back-to-back. const char* p = elem + fieldNameSize + 1; - if (bufSize == 0) { - size_t len1 = strlen(p); - p = p + len1 + 1; - size_t len2 = strlen(p); - return (len1 + 1 + len2 + 1) + fieldNameSize + 1; - } else { - int searchSize = bufSize - fieldNameSize - 1; - int len1 = strnlen(p, searchSize); - if (len1 == searchSize) - return -1; - p = p + len1 + 1; - searchSize -= len1 + 1; - int len2 = strnlen(p, searchSize); - if (len2 == searchSize) - return -1; - return (len1 + 1 + len2 + 1) + fieldNameSize + 1; - } + size_t len1 = strlen(p); + p = p + len1 + 1; + size_t len2 = strlen(p); + return (len1 + 1 + len2 + 1) + fieldNameSize + 1; } std::string BSONElement::toString(bool includeFieldName, bool full) const { |
