From 234b7a8b7d5b04a3bcc08c32d81488ee632485a2 Mon Sep 17 00:00:00 2001 From: mathisbessamdb <91484595+mathisbessamdb@users.noreply.github.com> Date: Fri, 17 Mar 2023 22:04:22 +0000 Subject: SERVER-71669 Remove TODO to no longer use StringData when manipulating TenantIds --- src/mongo/db/repl/cloner_utils.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/mongo/db/repl/cloner_utils.cpp') diff --git a/src/mongo/db/repl/cloner_utils.cpp b/src/mongo/db/repl/cloner_utils.cpp index cc281844aa6..ab858d85f95 100644 --- a/src/mongo/db/repl/cloner_utils.cpp +++ b/src/mongo/db/repl/cloner_utils.cpp @@ -56,10 +56,6 @@ BSONObj ClonerUtils::buildMajorityWaitRequest(Timestamp operationTime) { return bob.obj(); } -bool ClonerUtils::isDatabaseForTenant(StringData db, StringData prefix) { - return db.startsWith(prefix + "_"); -} - bool ClonerUtils::isDatabaseForTenant(const DatabaseName& db, const boost::optional& prefix, MigrationProtocolEnum protocol) { @@ -70,7 +66,12 @@ bool ClonerUtils::isDatabaseForTenant(const DatabaseName& db, if (db.tenantId()) { return *db.tenantId() == *prefix; } else { - return isDatabaseForTenant(db.toStringWithTenantId(), (*prefix).toString()); + auto fullDbName = db.db(); + auto tenantDelim = fullDbName.find('_'); + if (tenantDelim != std::string::npos) { + return (*prefix).toString() == fullDbName.substr(0, tenantDelim); + } + return false; } } @@ -79,7 +80,7 @@ bool ClonerUtils::isNamespaceForTenant(NamespaceString nss, StringData prefix) { if (gMultitenancySupport && nss.tenantId() != boost::none) { return nss.tenantId()->toString() == prefix; } - return isDatabaseForTenant(nss.db(), prefix); + return nss.db().startsWith(prefix + "_"); } } // namespace repl -- cgit v1.2.1