summaryrefslogtreecommitdiff
path: root/src/mongo/s
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/s')
-rw-r--r--src/mongo/s/catalog/type_chunk.cpp2
-rw-r--r--src/mongo/s/client/shard_remote.cpp2
-rw-r--r--src/mongo/s/commands/cluster_coll_stats_cmd.cpp45
3 files changed, 25 insertions, 24 deletions
diff --git a/src/mongo/s/catalog/type_chunk.cpp b/src/mongo/s/catalog/type_chunk.cpp
index 2ef043fe0f5..0d7e2fe36fa 100644
--- a/src/mongo/s/catalog/type_chunk.cpp
+++ b/src/mongo/s/catalog/type_chunk.cpp
@@ -131,7 +131,7 @@ const Status ChunkRange::extractKeyPattern(KeyPattern* shardKeyPatternOut) const
while (min.more() && max.more()) {
BSONElement x = min.next();
BSONElement y = max.next();
- if (!str::equals(x.fieldName(), y.fieldName()) || (min.more() && !max.more()) ||
+ if ((x.fieldNameStringData() != y.fieldNameStringData()) || (min.more() && !max.more()) ||
(!min.more() && max.more())) {
return {ErrorCodes::ShardKeyNotFound,
str::stream() << "the shard key of min " << _minKey << " doesn't match with "
diff --git a/src/mongo/s/client/shard_remote.cpp b/src/mongo/s/client/shard_remote.cpp
index 26d9b88daa1..76e0a98a8c8 100644
--- a/src/mongo/s/client/shard_remote.cpp
+++ b/src/mongo/s/client/shard_remote.cpp
@@ -79,7 +79,7 @@ BSONObj appendMaxTimeToCmdObj(Milliseconds maxTimeMSOverride, const BSONObj& cmd
// Remove the user provided maxTimeMS so we can attach the one from the override
for (const auto& elem : cmdObj) {
- if (!str::equals(elem.fieldName(), QueryRequest::cmdOptionMaxTimeMS)) {
+ if (elem.fieldNameStringData() != QueryRequest::cmdOptionMaxTimeMS) {
updatedCmdBuilder.append(elem);
}
}
diff --git a/src/mongo/s/commands/cluster_coll_stats_cmd.cpp b/src/mongo/s/commands/cluster_coll_stats_cmd.cpp
index 1f8d0498273..c9afc8df754 100644
--- a/src/mongo/s/commands/cluster_coll_stats_cmd.cpp
+++ b/src/mongo/s/commands/cluster_coll_stats_cmd.cpp
@@ -116,42 +116,43 @@ public:
// until we've iterated through all the fields before updating unscaledCollSize
const auto shardObjCount = static_cast<long long>(res["count"].Number());
+ auto fieldIsAnyOf = [](StringData v, std::initializer_list<StringData> il) {
+ auto ei = il.end();
+ return std::find(il.begin(), ei, v) != ei;
+ };
for (const auto& e : res) {
- if (str::equals(e.fieldName(), "ns") || //
- str::equals(e.fieldName(), "ok") || //
- str::equals(e.fieldName(), "lastExtentSize") || //
- str::equals(e.fieldName(), "paddingFactor")) {
- // Ignored fields
+ StringData fieldName = e.fieldNameStringData();
+ if (fieldIsAnyOf(fieldName, {"ns", "ok", "lastExtentSize", "paddingFactor"})) {
continue;
- } else if (str::equals(e.fieldName(), "userFlags") || //
- str::equals(e.fieldName(), "capped") || //
- str::equals(e.fieldName(), "max") || //
- str::equals(e.fieldName(), "paddingFactorNote") || //
- str::equals(e.fieldName(), "indexDetails") || //
- str::equals(e.fieldName(), "wiredTiger")) {
- // Fields that are copied from the first shard only, because they need to match
- // across shards
+ }
+ if (fieldIsAnyOf(fieldName,
+ {"userFlags",
+ "capped",
+ "max",
+ "paddingFactorNote",
+ "indexDetails",
+ "wiredTiger"})) {
+ // Fields that are copied from the first shard only, because they need to
+ // match across shards
if (!result.hasField(e.fieldName()))
result.append(e);
- } else if (str::equals(e.fieldName(), "count") || //
- str::equals(e.fieldName(), "size") || //
- str::equals(e.fieldName(), "storageSize") || //
- str::equals(e.fieldName(), "numExtents") || //
- str::equals(e.fieldName(), "totalIndexSize")) {
+ } else if (fieldIsAnyOf(
+ fieldName,
+ {"count", "size", "storageSize", "numExtents", "totalIndexSize"})) {
counts[e.fieldName()] += e.numberLong();
- } else if (str::equals(e.fieldName(), "avgObjSize")) {
+ } else if (fieldName == "avgObjSize") {
const auto shardAvgObjSize = e.numberLong();
unscaledCollSize += shardAvgObjSize * shardObjCount;
- } else if (str::equals(e.fieldName(), "maxSize")) {
+ } else if (fieldName == "maxSize") {
const auto shardMaxSize = e.numberLong();
maxSize = std::max(maxSize, shardMaxSize);
- } else if (str::equals(e.fieldName(), "indexSizes")) {
+ } else if (fieldName == "indexSizes") {
BSONObjIterator k(e.Obj());
while (k.more()) {
BSONElement temp = k.next();
indexSizes[temp.fieldName()] += temp.numberLong();
}
- } else if (str::equals(e.fieldName(), "nindexes")) {
+ } else if (fieldName == "nindexes") {
int myIndexes = e.numberInt();
if (nindexes == 0) {