diff options
author | Justin Seyster <justin.seyster@mongodb.com> | 2020-07-15 14:45:50 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-07-15 22:31:52 +0000 |
commit | 8dd68436b1347849877b013face3184565615636 (patch) | |
tree | 429518548c711686365d93b1477ac6235a8ed6a6 /src/mongo/bson | |
parent | eaaee39e2c4eaf9938c5a75bce30648435ae10cc (diff) | |
download | mongo-8dd68436b1347849877b013face3184565615636.tar.gz |
SERVER-49351 Implement readKeyStringValueIntoAccessors()
This unreverts commit 0daf2a1c327da1af9c53009cca44a6597373c482
Diffstat (limited to 'src/mongo/bson')
-rw-r--r-- | src/mongo/bson/ordering.h | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/mongo/bson/ordering.h b/src/mongo/bson/ordering.h index 1521044d468..d1178623f91 100644 --- a/src/mongo/bson/ordering.h +++ b/src/mongo/bson/ordering.h @@ -39,11 +39,12 @@ namespace mongo { * Over time we should push this up higher and higher. */ class Ordering { - unsigned bits; - Ordering(unsigned b) : bits(b) {} + uint32_t bits; + Ordering(uint32_t b) : bits(b) {} public: static constexpr size_t kMaxCompoundIndexKeys = size_t{32}; + static_assert(kMaxCompoundIndexKeys == 8 * sizeof(bits)); static Ordering allAscending() { return {0}; @@ -62,24 +63,24 @@ public: uassert(ErrorCodes::Overflow, str::stream() << "Ordering offset is out of bounds: " << i, i >= 0 && static_cast<size_t>(i) < kMaxCompoundIndexKeys); - return ((1 << i) & bits) ? -1 : 1; + return ((1u << i) & bits) ? -1 : 1; } - unsigned descending(unsigned mask) const { + uint32_t descending(uint32_t mask) const { return bits & mask; } static Ordering make(const BSONObj& obj) { - unsigned b = 0; + uint32_t b = 0; BSONObjIterator k(obj); - unsigned n = 0; + uint32_t n = 0; while (1) { BSONElement e = k.next(); if (e.eoo()) break; uassert(13103, "too many compound keys", n < kMaxCompoundIndexKeys); if (e.number() < 0) - b |= (1 << n); + b |= (1u << n); n++; } return Ordering(b); |