diff options
Diffstat (limited to 'src/mongo/db/namespace_string.h')
-rw-r--r-- | src/mongo/db/namespace_string.h | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/mongo/db/namespace_string.h b/src/mongo/db/namespace_string.h index 68323b5fad9..1277cb56d7a 100644 --- a/src/mongo/db/namespace_string.h +++ b/src/mongo/db/namespace_string.h @@ -839,15 +839,14 @@ private: ns.find('\0') == std::string::npos); auto dotIndex = ns.find('.'); + uint8_t dbNameSize = dotIndex != std::string::npos ? dotIndex : ns.size(); uassert(ErrorCodes::InvalidNamespace, fmt::format("db name must be at most {} characters, found: {}", DatabaseName::kMaxDatabaseNameLength, - dotIndex), - (dotIndex != std::string::npos ? dotIndex : ns.size()) <= - DatabaseName::kMaxDatabaseNameLength); + dbNameSize), + dbNameSize <= DatabaseName::kMaxDatabaseNameLength); - uint8_t details = - (dotIndex != std::string::npos ? dotIndex : ns.size()) & kDatabaseNameOffsetEndMask; + uint8_t details = dbNameSize & kDatabaseNameOffsetEndMask; size_t dbStartIndex = kDataOffset; if (tenantId) { dbStartIndex += OID::kOIDSize; |