summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorBilly Donahue <billy.donahue@mongodb.com>2019-04-03 18:16:29 -0400
committerBilly Donahue <billy.donahue@mongodb.com>2019-04-08 12:15:08 -0400
commit573921791c4d20e0d1603fd0a200d90d74b65bd5 (patch)
tree9ec3957126fecc636cb31874376f09b6161965ff /src/mongo/db
parentf8f872e029ba3b1f32d8499c912756d48dc1a03b (diff)
downloadmongo-573921791c4d20e0d1603fd0a200d90d74b65bd5.tar.gz
SERVER-40476 remove mongoutils::str::equals
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/catalog/index_key_validate.cpp4
-rw-r--r--src/mongo/db/commands/list_collections.cpp4
-rw-r--r--src/mongo/db/commands/mr.cpp2
-rw-r--r--src/mongo/db/exec/projection.cpp2
-rw-r--r--src/mongo/db/exec/projection_exec.cpp12
-rw-r--r--src/mongo/db/fts/fts_spec.cpp23
-rw-r--r--src/mongo/db/fts/fts_spec_legacy.cpp17
-rw-r--r--src/mongo/db/geo/geometry_container.cpp2
-rw-r--r--src/mongo/db/geo/geoparser.cpp12
-rw-r--r--src/mongo/db/keypattern.cpp2
-rw-r--r--src/mongo/db/matcher/expression_geo.cpp24
-rw-r--r--src/mongo/db/pipeline/document_source_group.cpp6
-rw-r--r--src/mongo/db/pipeline/document_source_match.cpp11
-rw-r--r--src/mongo/db/pipeline/expression.cpp34
-rw-r--r--src/mongo/db/pipeline/expression_test.cpp4
-rw-r--r--src/mongo/db/query/canonical_query.cpp2
-rw-r--r--src/mongo/db/query/collation/collator_factory_icu.cpp9
-rw-r--r--src/mongo/db/query/index_bounds_builder.cpp7
-rw-r--r--src/mongo/db/query/killcursors_request.cpp4
-rw-r--r--src/mongo/db/query/parsed_projection.cpp10
-rw-r--r--src/mongo/db/query/query_planner.cpp4
-rw-r--r--src/mongo/db/query/query_request.cpp26
-rw-r--r--src/mongo/db/repl/collection_cloner_test.cpp2
-rw-r--r--src/mongo/db/repl/database_cloner_test.cpp2
-rw-r--r--src/mongo/db/repl/databases_cloner_test.cpp2
-rw-r--r--src/mongo/db/repl/oplog.cpp8
-rw-r--r--src/mongo/db/s/check_sharding_index_command.cpp2
-rw-r--r--src/mongo/db/s/config/configsvr_shard_collection_command.cpp2
-rw-r--r--src/mongo/db/s/shardsvr_shard_collection.cpp13
29 files changed, 125 insertions, 127 deletions
diff --git a/src/mongo/db/catalog/index_key_validate.cpp b/src/mongo/db/catalog/index_key_validate.cpp
index 1927e0c74ae..c63f2530d20 100644
--- a/src/mongo/db/catalog/index_key_validate.cpp
+++ b/src/mongo/db/catalog/index_key_validate.cpp
@@ -199,11 +199,11 @@ Status validateKeyPattern(const BSONObj& key, IndexDescriptor::IndexVersion inde
}
// "$**" is acceptable for a text index or wildcard index.
- if (mongoutils::str::equals(keyElement.fieldName(), "$**") &&
+ if ((keyElement.fieldNameStringData() == "$**") &&
((keyElement.isNumber()) || (keyElement.valuestrsafe() == IndexNames::TEXT)))
continue;
- if (mongoutils::str::equals(keyElement.fieldName(), "_fts") &&
+ if ((keyElement.fieldNameStringData() == "_fts") &&
keyElement.valuestrsafe() != IndexNames::TEXT) {
return Status(code, "Index key contains an illegal field name: '_fts'");
}
diff --git a/src/mongo/db/commands/list_collections.cpp b/src/mongo/db/commands/list_collections.cpp
index 9080535db4a..1ddf5820be2 100644
--- a/src/mongo/db/commands/list_collections.cpp
+++ b/src/mongo/db/commands/list_collections.cpp
@@ -90,7 +90,7 @@ boost::optional<vector<StringData>> _getExactNameMatches(const MatchExpression*
if (matchType == MatchExpression::EQ) {
auto eqMatch = checked_cast<const EqualityMatchExpression*>(matcher);
if (eqMatch->path() == "name") {
- StringData name(eqMatch->getData().valuestrsafe());
+ StringData name(eqMatch->getData().valueStringDataSafe());
if (name.size()) {
return {vector<StringData>{name}};
} else {
@@ -102,7 +102,7 @@ boost::optional<vector<StringData>> _getExactNameMatches(const MatchExpression*
if (matchIn->path() == "name" && matchIn->getRegexes().empty()) {
vector<StringData> exactMatches;
for (auto&& elem : matchIn->getEqualities()) {
- StringData name(elem.valuestrsafe());
+ StringData name(elem.valueStringDataSafe());
if (name.size()) {
exactMatches.push_back(elem.valueStringData());
}
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index 217db0ed3d5..99dacfecbfa 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -558,7 +558,7 @@ void State::prepTempCollection() {
BSONObjIterator j(currIndex->infoObj());
while (j.more()) {
BSONElement e = j.next();
- if (str::equals(e.fieldName(), "_id") || str::equals(e.fieldName(), "ns"))
+ if (e.fieldNameStringData() == "_id" || e.fieldNameStringData() == "ns")
continue;
b.append(e);
}
diff --git a/src/mongo/db/exec/projection.cpp b/src/mongo/db/exec/projection.cpp
index 2b8984ead68..33ecf709de9 100644
--- a/src/mongo/db/exec/projection.cpp
+++ b/src/mongo/db/exec/projection.cpp
@@ -136,7 +136,7 @@ void ProjectionStage::getSimpleInclusionFields(const BSONObj& projObj, FieldSet*
BSONElement elt = projObjIt.next();
// Must deal with the _id case separately as there is an implicit _id: 1 in the
// projection.
- if (mongoutils::str::equals(elt.fieldName(), kIdField) && !elt.trueValue()) {
+ if ((elt.fieldNameStringData() == kIdField) && !elt.trueValue()) {
includeId = false;
continue;
}
diff --git a/src/mongo/db/exec/projection_exec.cpp b/src/mongo/db/exec/projection_exec.cpp
index f30eedaf6d8..987ce85252b 100644
--- a/src/mongo/db/exec/projection_exec.cpp
+++ b/src/mongo/db/exec/projection_exec.cpp
@@ -61,7 +61,7 @@ ProjectionExec::ProjectionExec(OperationContext* opCtx,
invariant(1 == obj.nFields());
BSONElement e2 = obj.firstElement();
- if (mongoutils::str::equals(e2.fieldName(), "$slice")) {
+ if (e2.fieldNameStringData() == "$slice") {
if (e2.isNumber()) {
int i = e2.numberInt();
if (i < 0) {
@@ -82,7 +82,7 @@ ProjectionExec::ProjectionExec(OperationContext* opCtx,
add(e.fieldName(), skip, limit);
}
- } else if (mongoutils::str::equals(e2.fieldName(), "$elemMatch")) {
+ } else if (e2.fieldNameStringData() == "$elemMatch") {
_arrayOpType = ARRAY_OP_ELEM_MATCH;
// Create a MatchExpression for the elemMatch.
@@ -99,7 +99,7 @@ ProjectionExec::ProjectionExec(OperationContext* opCtx,
statusWithMatcher.getValue().release();
add(e.fieldName(), true);
- } else if (mongoutils::str::equals(e2.fieldName(), "$meta")) {
+ } else if (e2.fieldNameStringData() == "$meta") {
invariant(String == e2.type());
if (e2.valuestr() == QueryRequest::metaTextScore) {
_meta[e.fieldName()] = META_TEXT_SCORE;
@@ -125,7 +125,7 @@ ProjectionExec::ProjectionExec(OperationContext* opCtx,
} else {
MONGO_UNREACHABLE;
}
- } else if (mongoutils::str::equals(e.fieldName(), "_id") && !e.trueValue()) {
+ } else if ((e.fieldNameStringData() == "_id") && !e.trueValue()) {
_includeID = false;
} else {
add(e.fieldName(), e.trueValue());
@@ -258,7 +258,7 @@ StatusWith<BSONObj> ProjectionExec::projectCovered(const std::vector<IndexKeyDat
mmb::Document projectedDoc;
for (auto&& specElt : _source) {
- if (mongoutils::str::equals("_id", specElt.fieldName())) {
+ if (specElt.fieldNameStringData() == "_id") {
continue;
}
@@ -340,7 +340,7 @@ Status ProjectionExec::projectHelper(const BSONObj& in,
BSONElement elt = it.next();
// Case 1: _id
- if (mongoutils::str::equals("_id", elt.fieldName())) {
+ if ("_id" == elt.fieldNameStringData()) {
if (_includeID) {
bob->append(elt);
}
diff --git a/src/mongo/db/fts/fts_spec.cpp b/src/mongo/db/fts/fts_spec.cpp
index 49271fa99df..14bb7b8bfdc 100644
--- a/src/mongo/db/fts/fts_spec.cpp
+++ b/src/mongo/db/fts/fts_spec.cpp
@@ -147,7 +147,7 @@ FTSSpec::FTSSpec(const BSONObj& indexInfo) {
while (i.more()) {
BSONElement e = i.next();
- if (str::equals(e.fieldName(), "_fts") || str::equals(e.fieldName(), "_ftsx")) {
+ if ((e.fieldNameStringData() == "_fts") || (e.fieldNameStringData() == "_ftsx")) {
passedFTS = true;
continue;
}
@@ -293,13 +293,13 @@ StatusWith<BSONObj> FTSSpec::fixSpec(const BSONObj& spec) {
BSONObjIterator i(spec["key"].Obj());
while (i.more()) {
BSONElement e = i.next();
- if (str::equals(e.fieldName(), "_fts")) {
+ if (e.fieldNameStringData() == "_fts") {
if (INDEX_NAME != e.valuestrsafe()) {
return {ErrorCodes::CannotCreateIndex, "expecting _fts:\"text\""};
}
addedFtsStuff = true;
b.append(e);
- } else if (str::equals(e.fieldName(), "_ftsx")) {
+ } else if (e.fieldNameStringData() == "_ftsx") {
if (e.numberInt() != 1) {
return {ErrorCodes::CannotCreateIndex, "expecting _ftsx:1"};
}
@@ -346,13 +346,13 @@ StatusWith<BSONObj> FTSSpec::fixSpec(const BSONObj& spec) {
}
// text fields
- bool alreadyFixed = str::equals(e.fieldName(), "_fts");
+ bool alreadyFixed = (e.fieldNameStringData() == "_fts");
if (alreadyFixed) {
if (!i.more()) {
return {ErrorCodes::CannotCreateIndex, "expected _ftsx after _fts"};
}
e = i.next();
- if (!str::equals(e.fieldName(), "_ftsx")) {
+ if (e.fieldNameStringData() != "_ftsx") {
return {ErrorCodes::CannotCreateIndex, "expected _ftsx after _fts"};
}
e = i.next();
@@ -468,20 +468,21 @@ StatusWith<BSONObj> FTSSpec::fixSpec(const BSONObj& spec) {
BSONObjIterator i(spec);
while (i.more()) {
BSONElement e = i.next();
- if (str::equals(e.fieldName(), "key")) {
+ StringData fieldName = e.fieldNameStringData();
+ if (fieldName == "key") {
b.append("key", keyPattern);
- } else if (str::equals(e.fieldName(), "weights")) {
+ } else if (fieldName == "weights") {
b.append("weights", weights);
weights = BSONObj();
- } else if (str::equals(e.fieldName(), "default_language")) {
+ } else if (fieldName == "default_language") {
b.append("default_language", default_language);
default_language = "";
- } else if (str::equals(e.fieldName(), "language_override")) {
+ } else if (fieldName == "language_override") {
b.append("language_override", language_override);
language_override = "";
- } else if (str::equals(e.fieldName(), "v")) {
+ } else if (fieldName == "v") {
version = e.numberInt();
- } else if (str::equals(e.fieldName(), "textIndexVersion")) {
+ } else if (fieldName == "textIndexVersion") {
if (!e.isNumber()) {
return {ErrorCodes::CannotCreateIndex,
"text index option 'textIndexVersion' must be a number"};
diff --git a/src/mongo/db/fts/fts_spec_legacy.cpp b/src/mongo/db/fts/fts_spec_legacy.cpp
index f1e244c616e..dcb7357166b 100644
--- a/src/mongo/db/fts/fts_spec_legacy.cpp
+++ b/src/mongo/db/fts/fts_spec_legacy.cpp
@@ -206,11 +206,11 @@ StatusWith<BSONObj> FTSSpec::_fixSpecV1(const BSONObj& spec) {
BSONObjIterator i(spec["key"].Obj());
while (i.more()) {
BSONElement e = i.next();
- if (str::equals(e.fieldName(), "_fts") || str::equals(e.fieldName(), "_ftsx")) {
+ if ((e.fieldNameStringData() == "_fts") || (e.fieldNameStringData() == "_ftsx")) {
addedFtsStuff = true;
b.append(e);
} else if (e.type() == String &&
- (str::equals("fts", e.valuestr()) || str::equals("text", e.valuestr()))) {
+ (e.valueStringData() == "fts" || e.valueStringData() == "text")) {
if (!addedFtsStuff) {
_addFTSStuff(&b);
addedFtsStuff = true;
@@ -269,20 +269,21 @@ StatusWith<BSONObj> FTSSpec::_fixSpecV1(const BSONObj& spec) {
BSONObjIterator i(spec);
while (i.more()) {
BSONElement e = i.next();
- if (str::equals(e.fieldName(), "key")) {
+ StringData fieldName = e.fieldNameStringData();
+ if (fieldName == "key") {
b.append("key", keyPattern);
- } else if (str::equals(e.fieldName(), "weights")) {
+ } else if (fieldName == "weights") {
b.append("weights", weights);
weights = BSONObj();
- } else if (str::equals(e.fieldName(), "default_language")) {
+ } else if (fieldName == "default_language") {
b.append("default_language", default_language);
default_language = "";
- } else if (str::equals(e.fieldName(), "language_override")) {
+ } else if (fieldName == "language_override") {
b.append("language_override", language_override);
language_override = "";
- } else if (str::equals(e.fieldName(), "v")) {
+ } else if (fieldName == "v") {
version = e.numberInt();
- } else if (str::equals(e.fieldName(), "textIndexVersion")) {
+ } else if (fieldName == "textIndexVersion") {
textIndexVersion = e.numberInt();
if (textIndexVersion != 1) {
return {ErrorCodes::CannotCreateIndex,
diff --git a/src/mongo/db/geo/geometry_container.cpp b/src/mongo/db/geo/geometry_container.cpp
index 2d529afd8aa..bea64bf8f0f 100644
--- a/src/mongo/db/geo/geometry_container.cpp
+++ b/src/mongo/db/geo/geometry_container.cpp
@@ -36,8 +36,6 @@
namespace mongo {
-using mongoutils::str::equals;
-
bool GeometryContainer::isSimpleContainer() const {
return NULL != _point || NULL != _line || NULL != _polygon;
}
diff --git a/src/mongo/db/geo/geoparser.cpp b/src/mongo/db/geo/geoparser.cpp
index 4156f4d7b77..c5a723805b2 100644
--- a/src/mongo/db/geo/geoparser.cpp
+++ b/src/mongo/db/geo/geoparser.cpp
@@ -776,16 +776,16 @@ GeoParser::GeoSpecifier GeoParser::parseGeoSpecifier(const BSONElement& type) {
if (!type.isABSONObj()) {
return GeoParser::UNKNOWN;
}
- const char* fieldName = type.fieldName();
- if (mongoutils::str::equals(fieldName, "$box")) {
+ StringData fieldName = type.fieldNameStringData();
+ if (fieldName == "$box") {
return GeoParser::BOX;
- } else if (mongoutils::str::equals(fieldName, "$center")) {
+ } else if (fieldName == "$center") {
return GeoParser::CENTER;
- } else if (mongoutils::str::equals(fieldName, "$polygon")) {
+ } else if (fieldName == "$polygon") {
return GeoParser::POLYGON;
- } else if (mongoutils::str::equals(fieldName, "$centerSphere")) {
+ } else if (fieldName == "$centerSphere") {
return GeoParser::CENTER_SPHERE;
- } else if (mongoutils::str::equals(fieldName, "$geometry")) {
+ } else if (fieldName == "$geometry") {
return GeoParser::GEOMETRY;
}
return GeoParser::UNKNOWN;
diff --git a/src/mongo/db/keypattern.cpp b/src/mongo/db/keypattern.cpp
index f0cb5df21dc..67fd8b08460 100644
--- a/src/mongo/db/keypattern.cpp
+++ b/src/mongo/db/keypattern.cpp
@@ -98,7 +98,7 @@ BSONObj KeyPattern::extendRangeBound(const BSONObj& bound, bool makeUpperInclusi
str::stream() << "field names of bound " << bound
<< " do not match those of keyPattern "
<< _pattern,
- str::equals(srcElt.fieldName(), patElt.fieldName()));
+ srcElt.fieldNameStringData() == patElt.fieldNameStringData());
newBound.append(srcElt);
}
while (pat.more()) {
diff --git a/src/mongo/db/matcher/expression_geo.cpp b/src/mongo/db/matcher/expression_geo.cpp
index b25ee5cf19e..34596d34c45 100644
--- a/src/mongo/db/matcher/expression_geo.cpp
+++ b/src/mongo/db/matcher/expression_geo.cpp
@@ -40,9 +40,6 @@
namespace mongo {
-
-using mongoutils::str::equals;
-
//
// GeoExpression
//
@@ -80,7 +77,7 @@ Status GeoExpression::parseQuery(const BSONObj& obj) {
while (geoIt.more()) {
BSONElement elt = geoIt.next();
- if (str::equals(elt.fieldName(), "$uniqueDocs")) {
+ if (elt.fieldNameStringData() == "$uniqueDocs") {
// Deprecated "$uniqueDocs" field
warning() << "deprecated $uniqueDocs option: " << redact(obj);
} else {
@@ -175,8 +172,8 @@ bool GeoNearExpression::parseLegacyQuery(const BSONObj& obj) {
BSONObjIterator it(obj);
while (it.more()) {
BSONElement e = it.next();
- if (equals(e.fieldName(), "$near") || equals(e.fieldName(), "$geoNear") ||
- equals(e.fieldName(), "$nearSphere")) {
+ StringData fieldName = e.fieldNameStringData();
+ if ((fieldName == "$near") || (fieldName == "$geoNear") || (fieldName == "$nearSphere")) {
if (!e.isABSONObj()) {
return false;
}
@@ -186,17 +183,17 @@ bool GeoNearExpression::parseLegacyQuery(const BSONObj& obj) {
GeoParser::parsePointWithMaxDistance(embeddedObj, centroid.get(), &maxDistance)) {
uassert(18522, "max distance must be non-negative", maxDistance >= 0.0);
hasGeometry = true;
- isNearSphere = equals(e.fieldName(), "$nearSphere");
+ isNearSphere = (e.fieldNameStringData() == "$nearSphere");
}
- } else if (equals(e.fieldName(), "$minDistance")) {
+ } else if (fieldName == "$minDistance") {
uassert(16893, "$minDistance must be a number", e.isNumber());
minDistance = e.Number();
uassert(16894, "$minDistance must be non-negative", minDistance >= 0.0);
- } else if (equals(e.fieldName(), "$maxDistance")) {
+ } else if (fieldName == "$maxDistance") {
uassert(16895, "$maxDistance must be a number", e.isNumber());
maxDistance = e.Number();
uassert(16896, "$maxDistance must be non-negative", maxDistance >= 0.0);
- } else if (equals(e.fieldName(), "$uniqueDocs")) {
+ } else if (fieldName == "$uniqueDocs") {
warning() << "ignoring deprecated option $uniqueDocs";
} else {
// In a query document, $near queries can have no non-geo sibling parameters.
@@ -242,7 +239,8 @@ Status GeoNearExpression::parseNewQuery(const BSONObj& obj) {
BSONObjIterator it(e.embeddedObject());
while (it.more()) {
BSONElement e = it.next();
- if (equals(e.fieldName(), "$geometry")) {
+ StringData fieldName = e.fieldNameStringData();
+ if (fieldName == "$geometry") {
if (e.isABSONObj()) {
BSONObj embeddedObj = e.embeddedObject();
Status status = GeoParser::parseQueryPoint(e, centroid.get());
@@ -259,11 +257,11 @@ Status GeoNearExpression::parseNewQuery(const BSONObj& obj) {
(SPHERE == centroid->crs));
hasGeometry = true;
}
- } else if (equals(e.fieldName(), "$minDistance")) {
+ } else if (fieldName == "$minDistance") {
uassert(16897, "$minDistance must be a number", e.isNumber());
minDistance = e.Number();
uassert(16898, "$minDistance must be non-negative", minDistance >= 0.0);
- } else if (equals(e.fieldName(), "$maxDistance")) {
+ } else if (fieldName == "$maxDistance") {
uassert(16899, "$maxDistance must be a number", e.isNumber());
maxDistance = e.Number();
uassert(16900, "$maxDistance must be non-negative", maxDistance >= 0.0);
diff --git a/src/mongo/db/pipeline/document_source_group.cpp b/src/mongo/db/pipeline/document_source_group.cpp
index fa006b78b0c..9625bc65d97 100644
--- a/src/mongo/db/pipeline/document_source_group.cpp
+++ b/src/mongo/db/pipeline/document_source_group.cpp
@@ -396,14 +396,14 @@ intrusive_ptr<DocumentSource> DocumentSourceGroup::createFromBson(
VariablesParseState vps = pExpCtx->variablesParseState;
while (groupIterator.more()) {
BSONElement groupField(groupIterator.next());
- const char* pFieldName = groupField.fieldName();
+ StringData pFieldName = groupField.fieldNameStringData();
- if (str::equals(pFieldName, "_id")) {
+ if (pFieldName == "_id") {
uassert(
15948, "a group's _id may only be specified once", pGroup->_idExpressions.empty());
pGroup->setIdExpression(parseIdExpression(pExpCtx, groupField, vps));
invariant(!pGroup->_idExpressions.empty());
- } else if (str::equals(pFieldName, "$doingMerge")) {
+ } else if (pFieldName == "$doingMerge") {
massert(17030, "$doingMerge should be true if present", groupField.Bool());
pGroup->setDoingMerge(true);
diff --git a/src/mongo/db/pipeline/document_source_match.cpp b/src/mongo/db/pipeline/document_source_match.cpp
index 7cb3bcec620..0a269db2451 100644
--- a/src/mongo/db/pipeline/document_source_match.cpp
+++ b/src/mongo/db/pipeline/document_source_match.cpp
@@ -298,9 +298,10 @@ Document redactSafePortionDollarOps(BSONObj expr) {
// the expression can safely be promoted in front of a $redact.
Document redactSafePortionTopLevel(BSONObj query) {
MutableDocument output;
- BSONForEach(field, query) {
- if (field.fieldName()[0] == '$') {
- if (str::equals(field.fieldName(), "$or")) {
+ for (BSONElement field : query) {
+ StringData fieldName = field.fieldNameStringData();
+ if (fieldName.startsWith("$")) {
+ if (fieldName == "$or") {
// $or must be all-or-nothing (line $in). Can't include subset of elements.
vector<Value> okClauses;
BSONForEach(elem, field.Obj()) {
@@ -314,7 +315,7 @@ Document redactSafePortionTopLevel(BSONObj query) {
if (!okClauses.empty())
output["$or"] = Value(std::move(okClauses));
- } else if (str::equals(field.fieldName(), "$and")) {
+ } else if (fieldName == "$and") {
// $and can include subset of elements (like $all).
vector<Value> okClauses;
BSONForEach(elem, field.Obj()) {
@@ -356,7 +357,7 @@ Document redactSafePortionTopLevel(BSONObj query) {
}
return output.freeze();
}
-}
+} // namespace
BSONObj DocumentSourceMatch::redactSafePortion() const {
return redactSafePortionTopLevel(getQuery()).toBson();
diff --git a/src/mongo/db/pipeline/expression.cpp b/src/mongo/db/pipeline/expression.cpp
index d61854b3ba3..864ca057945 100644
--- a/src/mongo/db/pipeline/expression.cpp
+++ b/src/mongo/db/pipeline/expression.cpp
@@ -906,18 +906,18 @@ intrusive_ptr<Expression> ExpressionCond::parse(
if (expr.type() != Object) {
return Base::parse(expCtx, expr, vps);
}
- verify(str::equals(expr.fieldName(), "$cond"));
+ verify(expr.fieldNameStringData() == "$cond");
intrusive_ptr<ExpressionCond> ret = new ExpressionCond(expCtx);
ret->vpOperand.resize(3);
const BSONObj args = expr.embeddedObject();
BSONForEach(arg, args) {
- if (str::equals(arg.fieldName(), "if")) {
+ if (arg.fieldNameStringData() == "if") {
ret->vpOperand[0] = parseOperand(expCtx, arg, vps);
- } else if (str::equals(arg.fieldName(), "then")) {
+ } else if (arg.fieldNameStringData() == "then") {
ret->vpOperand[1] = parseOperand(expCtx, arg, vps);
- } else if (str::equals(arg.fieldName(), "else")) {
+ } else if (arg.fieldNameStringData() == "else") {
ret->vpOperand[2] = parseOperand(expCtx, arg, vps);
} else {
uasserted(17083,
@@ -1640,7 +1640,7 @@ intrusive_ptr<Expression> ExpressionDateToString::parse(
const boost::intrusive_ptr<ExpressionContext>& expCtx,
BSONElement expr,
const VariablesParseState& vps) {
- verify(str::equals(expr.fieldName(), "$dateToString"));
+ verify(expr.fieldNameStringData() == "$dateToString");
uassert(18629,
"$dateToString only supports an object as its argument",
@@ -2110,7 +2110,7 @@ intrusive_ptr<Expression> ExpressionFilter::parse(
const boost::intrusive_ptr<ExpressionContext>& expCtx,
BSONElement expr,
const VariablesParseState& vpsIn) {
- verify(str::equals(expr.fieldName(), "$filter"));
+ verify(expr.fieldNameStringData() == "$filter");
uassert(28646, "$filter only supports an object as its argument", expr.type() == Object);
@@ -2119,11 +2119,11 @@ intrusive_ptr<Expression> ExpressionFilter::parse(
BSONElement asElem;
BSONElement condElem;
for (auto elem : expr.Obj()) {
- if (str::equals(elem.fieldName(), "input")) {
+ if (elem.fieldNameStringData() == "input") {
inputElem = elem;
- } else if (str::equals(elem.fieldName(), "as")) {
+ } else if (elem.fieldNameStringData() == "as") {
asElem = elem;
- } else if (str::equals(elem.fieldName(), "cond")) {
+ } else if (elem.fieldNameStringData() == "cond") {
condElem = elem;
} else {
uasserted(28647,
@@ -2239,7 +2239,7 @@ intrusive_ptr<Expression> ExpressionLet::parse(
const boost::intrusive_ptr<ExpressionContext>& expCtx,
BSONElement expr,
const VariablesParseState& vpsIn) {
- verify(str::equals(expr.fieldName(), "$let"));
+ verify(expr.fieldNameStringData() == "$let");
uassert(16874, "$let only supports an object as its argument", expr.type() == Object);
const BSONObj args = expr.embeddedObject();
@@ -2248,9 +2248,9 @@ intrusive_ptr<Expression> ExpressionLet::parse(
BSONElement varsElem;
BSONElement inElem;
BSONForEach(arg, args) {
- if (str::equals(arg.fieldName(), "vars")) {
+ if (arg.fieldNameStringData() == "vars") {
varsElem = arg;
- } else if (str::equals(arg.fieldName(), "in")) {
+ } else if (arg.fieldNameStringData() == "in") {
inElem = arg;
} else {
uasserted(16875,
@@ -2338,7 +2338,7 @@ intrusive_ptr<Expression> ExpressionMap::parse(
const boost::intrusive_ptr<ExpressionContext>& expCtx,
BSONElement expr,
const VariablesParseState& vpsIn) {
- verify(str::equals(expr.fieldName(), "$map"));
+ verify(expr.fieldNameStringData() == "$map");
uassert(16878, "$map only supports an object as its argument", expr.type() == Object);
@@ -2348,11 +2348,11 @@ intrusive_ptr<Expression> ExpressionMap::parse(
BSONElement inElem;
const BSONObj args = expr.embeddedObject();
BSONForEach(arg, args) {
- if (str::equals(arg.fieldName(), "input")) {
+ if (arg.fieldNameStringData() == "input") {
inputElem = arg;
- } else if (str::equals(arg.fieldName(), "as")) {
+ } else if (arg.fieldNameStringData() == "as") {
asElem = arg;
- } else if (str::equals(arg.fieldName(), "in")) {
+ } else if (arg.fieldNameStringData() == "in") {
inElem = arg;
} else {
uasserted(16879,
@@ -3113,7 +3113,7 @@ intrusive_ptr<Expression> ExpressionNary::optimize() {
// is also associative, replace the expression for the operands it has.
// E.g: sum(a, b, sum(c, d), e) => sum(a, b, c, d, e)
ExpressionNary* nary = dynamic_cast<ExpressionNary*>(operand.get());
- if (nary && str::equals(nary->getOpName(), getOpName()) && nary->isAssociative()) {
+ if (nary && !strcmp(nary->getOpName(), getOpName()) && nary->isAssociative()) {
invariant(!nary->vpOperand.empty());
vpOperand[i] = std::move(nary->vpOperand[0]);
vpOperand.insert(
diff --git a/src/mongo/db/pipeline/expression_test.cpp b/src/mongo/db/pipeline/expression_test.cpp
index 5c2426217ab..62695188828 100644
--- a/src/mongo/db/pipeline/expression_test.cpp
+++ b/src/mongo/db/pipeline/expression_test.cpp
@@ -113,8 +113,8 @@ static BSONObj constify(const BSONObj& obj, bool parentIsArray = false) {
// arrays within arrays are treated as constant values by the real
// parser
bob << elem.fieldName() << BSONArray(constify(elem.Obj(), true));
- } else if (str::equals(elem.fieldName(), "$const") ||
- (elem.type() == mongo::String && elem.valuestrsafe()[0] == '$')) {
+ } else if (elem.fieldNameStringData() == "$const" ||
+ (elem.type() == mongo::String && elem.valueStringDataSafe().startsWith("$"))) {
bob.append(elem);
} else {
bob.append(elem.fieldName(), BSON("$const" << elem));
diff --git a/src/mongo/db/query/canonical_query.cpp b/src/mongo/db/query/canonical_query.cpp
index cf6fb23c661..0be2f524798 100644
--- a/src/mongo/db/query/canonical_query.cpp
+++ b/src/mongo/db/query/canonical_query.cpp
@@ -270,7 +270,7 @@ bool CanonicalQuery::isSimpleIdQuery(const BSONObj& query) {
BSONObjIterator it(query);
while (it.more()) {
BSONElement elt = it.next();
- if (str::equals("_id", elt.fieldName())) {
+ if (elt.fieldNameStringData() == "_id") {
// Verify that the query on _id is a simple equality.
hasID = true;
diff --git a/src/mongo/db/query/collation/collator_factory_icu.cpp b/src/mongo/db/query/collation/collator_factory_icu.cpp
index 5c891e02c4c..8c232d60025 100644
--- a/src/mongo/db/query/collation/collator_factory_icu.cpp
+++ b/src/mongo/db/query/collation/collator_factory_icu.cpp
@@ -46,7 +46,7 @@ namespace mongo {
namespace {
-const char kFallbackLocaleName[] = "root";
+constexpr StringData kFallbackLocaleName = "root"_sd;
// Helper methods for converting between ICU attributes and types used by CollationSpec.
@@ -646,13 +646,12 @@ Status validateLocaleID(const BSONObj& spec,
// resulting icu::Locale name will not match the requested locale. In this case we return an
// error to the user. In the error message to the user, we report the locale that ICU *would
// have* used, which the application can supply as an alternative.
- const char* collatorLocaleName = collatorLocale.getName();
- if (StringData(originalID) != StringData(collatorLocaleName)) {
+ auto collatorLocaleName = StringData(collatorLocale.getName());
+ if (originalID != collatorLocaleName) {
str::stream ss;
ss << "Field '" << CollationSpec::kLocaleField << "' is invalid in: " << spec;
- if (!str::equals(kFallbackLocaleName, collatorLocaleName) &&
- !str::equals("", collatorLocaleName)) {
+ if ((collatorLocaleName != kFallbackLocaleName) && !collatorLocaleName.empty()) {
ss << ". Did you mean '" << collatorLocaleName << "'?";
}
diff --git a/src/mongo/db/query/index_bounds_builder.cpp b/src/mongo/db/query/index_bounds_builder.cpp
index c86a43a5f10..43c5a55772c 100644
--- a/src/mongo/db/query/index_bounds_builder.cpp
+++ b/src/mongo/db/query/index_bounds_builder.cpp
@@ -361,7 +361,7 @@ void IndexBoundsBuilder::_translatePredicate(const MatchExpression* expr,
oilOut->name = elt.fieldName();
bool isHashed = false;
- if (mongoutils::str::equals("hashed", elt.valuestrsafe())) {
+ if (elt.valueStringDataSafe() == "hashed") {
isHashed = true;
}
@@ -716,15 +716,14 @@ void IndexBoundsBuilder::_translatePredicate(const MatchExpression* expr,
unionize(oilOut);
} else if (MatchExpression::GEO == expr->matchType()) {
const GeoMatchExpression* gme = static_cast<const GeoMatchExpression*>(expr);
-
- if (mongoutils::str::equals("2dsphere", elt.valuestrsafe())) {
+ if ("2dsphere" == elt.valueStringDataSafe()) {
verify(gme->getGeoExpression().getGeometry().hasS2Region());
const S2Region& region = gme->getGeoExpression().getGeometry().getS2Region();
S2IndexingParams indexParams;
ExpressionParams::initialize2dsphereParams(index.infoObj, index.collator, &indexParams);
ExpressionMapping::cover2dsphere(region, indexParams, oilOut);
*tightnessOut = IndexBoundsBuilder::INEXACT_FETCH;
- } else if (mongoutils::str::equals("2d", elt.valuestrsafe())) {
+ } else if ("2d" == elt.valueStringDataSafe()) {
verify(gme->getGeoExpression().getGeometry().hasR2Region());
const R2Region& region = gme->getGeoExpression().getGeometry().getR2Region();
diff --git a/src/mongo/db/query/killcursors_request.cpp b/src/mongo/db/query/killcursors_request.cpp
index 34ebc74c59c..df44d73043d 100644
--- a/src/mongo/db/query/killcursors_request.cpp
+++ b/src/mongo/db/query/killcursors_request.cpp
@@ -37,7 +37,7 @@ namespace mongo {
namespace {
-const char kCmdName[] = "killCursors";
+constexpr StringData kCmdName = "killCursors"_sd;
const char kCursorsField[] = "cursors";
} // namespace
@@ -48,7 +48,7 @@ KillCursorsRequest::KillCursorsRequest(const NamespaceString& nsString,
StatusWith<KillCursorsRequest> KillCursorsRequest::parseFromBSON(const std::string& dbname,
const BSONObj& cmdObj) {
- if (!str::equals(cmdObj.firstElement().fieldName(), kCmdName)) {
+ if (cmdObj.firstElement().fieldNameStringData() != kCmdName) {
return {ErrorCodes::FailedToParse,
str::stream() << "First field name must be '" << kCmdName << "' in: " << cmdObj};
}
diff --git a/src/mongo/db/query/parsed_projection.cpp b/src/mongo/db/query/parsed_projection.cpp
index bdd1909d97c..91b0156f8f4 100644
--- a/src/mongo/db/query/parsed_projection.cpp
+++ b/src/mongo/db/query/parsed_projection.cpp
@@ -78,7 +78,7 @@ Status ParsedProjection::make(OperationContext* opCtx,
}
BSONElement e2 = obj.firstElement();
- if (mongoutils::str::equals(e2.fieldName(), "$slice")) {
+ if (e2.fieldNameStringData() == "$slice") {
if (e2.isNumber()) {
// This is A-OK.
} else if (e2.type() == Array) {
@@ -102,7 +102,7 @@ Status ParsedProjection::make(OperationContext* opCtx,
// Projections with $slice aren't covered.
requiresDocument = true;
pp->_arrayFields.push_back(elem.fieldNameStringData());
- } else if (mongoutils::str::equals(e2.fieldName(), "$elemMatch")) {
+ } else if (e2.fieldNameStringData() == "$elemMatch") {
// Validate $elemMatch arguments and dependencies.
if (Object != e2.type()) {
return Status(ErrorCodes::BadValue,
@@ -147,7 +147,7 @@ Status ParsedProjection::make(OperationContext* opCtx,
// Projections with $elemMatch aren't covered.
requiresDocument = true;
pp->_arrayFields.push_back(elem.fieldNameStringData());
- } else if (mongoutils::str::equals(e2.fieldName(), "$meta")) {
+ } else if (e2.fieldNameStringData() == "$meta") {
// Field for meta must be top level. We can relax this at some point.
if (mongoutils::str::contains(elem.fieldName(), '.')) {
return Status(ErrorCodes::BadValue, "field for $meta cannot be nested");
@@ -190,7 +190,7 @@ Status ParsedProjection::make(OperationContext* opCtx,
return Status(ErrorCodes::BadValue,
string("Unsupported projection option: ") + elem.toString());
}
- } else if (mongoutils::str::equals(elem.fieldName(), "_id") && !elem.trueValue()) {
+ } else if ((elem.fieldNameStringData() == "_id") && !elem.trueValue()) {
pp->_hasId = false;
} else {
pp->_hasDottedFieldPath = pp->_hasDottedFieldPath ||
@@ -291,7 +291,7 @@ Status ParsedProjection::make(OperationContext* opCtx,
while (srcIt.more()) {
BSONElement elt = srcIt.next();
// We've already handled the _id field before entering this loop.
- if (pp->_hasId && mongoutils::str::equals(elt.fieldName(), "_id")) {
+ if (pp->_hasId && (elt.fieldNameStringData() == "_id")) {
continue;
}
// $meta sortKey should not be checked as a part of _requiredFields, since it can
diff --git a/src/mongo/db/query/query_planner.cpp b/src/mongo/db/query/query_planner.cpp
index 0a45ee45dca..d7503c724a8 100644
--- a/src/mongo/db/query/query_planner.cpp
+++ b/src/mongo/db/query/query_planner.cpp
@@ -79,7 +79,7 @@ static bool is2DIndex(const BSONObj& pattern) {
BSONObjIterator it(pattern);
while (it.more()) {
BSONElement e = it.next();
- if (String == e.type() && str::equals("2d", e.valuestr())) {
+ if (String == e.type() && (e.valueStringData() == "2d")) {
return true;
}
}
@@ -175,7 +175,7 @@ static bool indexCompatibleMaxMin(const BSONObj& obj,
// Field names must match and be in the same order.
BSONElement kpElt = kpIt.next();
BSONElement objElt = objIt.next();
- if (!mongoutils::str::equals(kpElt.fieldName(), objElt.fieldName())) {
+ if (kpElt.fieldNameStringData() != objElt.fieldNameStringData()) {
return false;
}
diff --git a/src/mongo/db/query/query_request.cpp b/src/mongo/db/query/query_request.cpp
index 7a990dd5b9f..6cdca0a5327 100644
--- a/src/mongo/db/query/query_request.cpp
+++ b/src/mongo/db/query/query_request.cpp
@@ -707,7 +707,7 @@ bool QueryRequest::isTextScoreMeta(BSONElement elt) {
return false;
}
BSONElement metaElt = metaIt.next();
- if (!str::equals("$meta", metaElt.fieldName())) {
+ if (metaElt.fieldNameStringData() != "$meta") {
return false;
}
if (mongo::String != metaElt.type()) {
@@ -838,9 +838,9 @@ Status QueryRequest::initFullQuery(const BSONObj& top) {
while (i.more()) {
BSONElement e = i.next();
- const char* name = e.fieldName();
+ StringData name = e.fieldNameStringData();
- if (0 == strcmp("$orderby", name) || 0 == strcmp("orderby", name)) {
+ if (name == "$orderby" || name == "orderby") {
if (Object == e.type()) {
_sort = e.embeddedObject().getOwned();
} else if (Array == e.type()) {
@@ -878,22 +878,22 @@ Status QueryRequest::initFullQuery(const BSONObj& top) {
} else {
return Status(ErrorCodes::BadValue, "sort must be object or array");
}
- } else if ('$' == *name) {
- name++;
- if (str::equals("explain", name)) {
+ } else if (name.startsWith("$")) {
+ name = name.substr(1); // chop first char
+ if (name == "explain") {
// Won't throw.
_explain = e.trueValue();
- } else if (str::equals("min", name)) {
+ } else if (name == "min") {
if (!e.isABSONObj()) {
return Status(ErrorCodes::BadValue, "$min must be a BSONObj");
}
_min = e.embeddedObject().getOwned();
- } else if (str::equals("max", name)) {
+ } else if (name == "max") {
if (!e.isABSONObj()) {
return Status(ErrorCodes::BadValue, "$max must be a BSONObj");
}
_max = e.embeddedObject().getOwned();
- } else if (str::equals("hint", name)) {
+ } else if (name == "hint") {
if (e.isABSONObj()) {
_hint = e.embeddedObject().getOwned();
} else if (String == e.type()) {
@@ -902,25 +902,25 @@ Status QueryRequest::initFullQuery(const BSONObj& top) {
return Status(ErrorCodes::BadValue,
"$hint must be either a string or nested object");
}
- } else if (str::equals("returnKey", name)) {
+ } else if (name == "returnKey") {
// Won't throw.
if (e.trueValue()) {
_returnKey = true;
addReturnKeyMetaProj();
}
- } else if (str::equals("showDiskLoc", name)) {
+ } else if (name == "showDiskLoc") {
// Won't throw.
if (e.trueValue()) {
_showRecordId = true;
addShowRecordIdMetaProj();
}
- } else if (str::equals("maxTimeMS", name)) {
+ } else if (name == "maxTimeMS") {
StatusWith<int> maxTimeMS = parseMaxTimeMS(e);
if (!maxTimeMS.isOK()) {
return maxTimeMS.getStatus();
}
_maxTimeMS = maxTimeMS.getValue();
- } else if (str::equals("comment", name)) {
+ } else if (name == "comment") {
// Legacy $comment can be any BSON element. Convert to string if it isn't
// already.
if (e.type() == BSONType::String) {
diff --git a/src/mongo/db/repl/collection_cloner_test.cpp b/src/mongo/db/repl/collection_cloner_test.cpp
index c8f06889825..4cb8147c75d 100644
--- a/src/mongo/db/repl/collection_cloner_test.cpp
+++ b/src/mongo/db/repl/collection_cloner_test.cpp
@@ -525,7 +525,7 @@ TEST_F(CollectionClonerTest,
CollectionClonerReturnsScheduleErrorOnFailingToScheduleListIndexesCommand) {
TaskExecutorWithFailureInScheduleRemoteCommand _executorProxy(
&getExecutor(), [](const executor::RemoteCommandRequest& request) {
- return str::equals("listIndexes", request.cmdObj.firstElementFieldName());
+ return request.cmdObj.firstElementFieldNameStringData() == "listIndexes";
});
collectionCloner = stdx::make_unique<CollectionCloner>(&_executorProxy,
diff --git a/src/mongo/db/repl/database_cloner_test.cpp b/src/mongo/db/repl/database_cloner_test.cpp
index 07f7bc7bfff..e9f3a6fee90 100644
--- a/src/mongo/db/repl/database_cloner_test.cpp
+++ b/src/mongo/db/repl/database_cloner_test.cpp
@@ -250,7 +250,7 @@ TEST_F(DatabaseClonerTest,
DatabaseClonerReturnsScheduleErrorOnFailingToScheduleListCollectionsCommand) {
TaskExecutorWithFailureInScheduleRemoteCommand executorProxy(
&getExecutor(), [](const executor::RemoteCommandRequest& request) {
- return str::equals("listCollections", request.cmdObj.firstElementFieldName());
+ return request.cmdObj.firstElementFieldNameStringData() == "listCollections";
});
DatabaseCloner databaseCloner(&executorProxy,
diff --git a/src/mongo/db/repl/databases_cloner_test.cpp b/src/mongo/db/repl/databases_cloner_test.cpp
index c4828eca321..f381077c4ab 100644
--- a/src/mongo/db/repl/databases_cloner_test.cpp
+++ b/src/mongo/db/repl/databases_cloner_test.cpp
@@ -791,7 +791,7 @@ TEST_F(DBsClonerTest, FailingToScheduleSecondDatabaseClonerShouldCancelTheCloner
TaskExecutorWithFailureInScheduleRemoteCommand _executorProxy(
&getExecutor(), [](const executor::RemoteCommandRequest& request) {
- return str::equals("listCollections", request.cmdObj.firstElementFieldName()) &&
+ return request.cmdObj.firstElementFieldNameStringData() == "listCollections" &&
request.dbname == "b";
});
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index 613683144e4..f421603e99f 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -1470,7 +1470,7 @@ Status applyOperation_inlock(OperationContext* opCtx,
uassert(ErrorCodes::InvalidNamespace,
"'ns' must be of type String",
fieldNs.type() == BSONType::String);
- const StringData ns = fieldNs.valuestrsafe();
+ const StringData ns = fieldNs.valueStringDataSafe();
requestNss = NamespaceString(ns);
invariant(requestNss.coll().size());
dassert(opCtx->lockState()->isCollectionLockedForMode(
@@ -1711,7 +1711,7 @@ Status applyOperation_inlock(OperationContext* opCtx,
request.setUpsert();
request.setFromOplogApplication(true);
- const StringData ns = fieldNs.valuestrsafe();
+ const StringData ns = fieldNs.valueStringDataSafe();
writeConflictRetry(opCtx, "applyOps_upsert", ns, [&] {
WriteUnitOfWork wuow(opCtx);
// If this is an atomic applyOps (i.e: `haveWrappingWriteUnitOfWork` is true),
@@ -1762,7 +1762,7 @@ Status applyOperation_inlock(OperationContext* opCtx,
timestamp = fieldTs.timestamp();
}
- const StringData ns = fieldNs.valuestrsafe();
+ const StringData ns = fieldNs.valueStringDataSafe();
auto status = writeConflictRetry(opCtx, "applyOps_update", ns, [&] {
WriteUnitOfWork wuow(opCtx);
if (timestamp != Timestamp::min()) {
@@ -1841,7 +1841,7 @@ Status applyOperation_inlock(OperationContext* opCtx,
timestamp = fieldTs.timestamp();
}
- const StringData ns = fieldNs.valuestrsafe();
+ const StringData ns = fieldNs.valueStringDataSafe();
writeConflictRetry(opCtx, "applyOps_delete", ns, [&] {
WriteUnitOfWork wuow(opCtx);
if (timestamp != Timestamp::min()) {
diff --git a/src/mongo/db/s/check_sharding_index_command.cpp b/src/mongo/db/s/check_sharding_index_command.cpp
index da7f1700869..7bc56741ae8 100644
--- a/src/mongo/db/s/check_sharding_index_command.cpp
+++ b/src/mongo/db/s/check_sharding_index_command.cpp
@@ -97,7 +97,7 @@ public:
return false;
}
- if (keyPattern.nFields() == 1 && str::equals("_id", keyPattern.firstElementFieldName())) {
+ if (keyPattern.nFields() == 1 && keyPattern.firstElementFieldNameStringData() == "_id") {
result.appendBool("idskip", true);
return true;
}
diff --git a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp
index cbbcee65059..30824550e1e 100644
--- a/src/mongo/db/s/config/configsvr_shard_collection_command.cpp
+++ b/src/mongo/db/s/config/configsvr_shard_collection_command.cpp
@@ -353,7 +353,7 @@ void validateShardKeyAgainstExistingIndexes(OperationContext* opCtx,
} else {
bool isExplicitlyUnique = eqQueryResult["unique"].trueValue();
BSONObj currKey = eqQueryResult["key"].embeddedObject();
- bool isCurrentID = str::equals(currKey.firstElementFieldName(), "_id");
+ bool isCurrentID = (currKey.firstElementFieldNameStringData() == "_id");
uassert(ErrorCodes::InvalidOptions,
str::stream() << "can't shard collection " << nss.ns() << ", " << proposedKey
<< " index not unique, and unique index explicitly specified",
diff --git a/src/mongo/db/s/shardsvr_shard_collection.cpp b/src/mongo/db/s/shardsvr_shard_collection.cpp
index e6bff1ed444..bfb106786f3 100644
--- a/src/mongo/db/s/shardsvr_shard_collection.cpp
+++ b/src/mongo/db/s/shardsvr_shard_collection.cpp
@@ -248,7 +248,7 @@ void createCollectionOrValidateExisting(OperationContext* opCtx,
} else {
bool isExplicitlyUnique = eqQueryResult["unique"].trueValue();
BSONObj currKey = eqQueryResult["key"].embeddedObject();
- bool isCurrentID = str::equals(currKey.firstElementFieldName(), "_id");
+ bool isCurrentID = (currKey.firstElementFieldNameStringData() == "_id");
uassert(ErrorCodes::InvalidOptions,
str::stream() << "can't shard collection " << nss.ns() << ", " << proposedKey
<< " index not unique, and unique index explicitly specified",
@@ -308,13 +308,14 @@ void validateShardKeyAgainstExistingZones(OperationContext* opCtx,
<< " -->> "
<< tag.getMaxKey()
<< " have non-matching keys",
- str::equals(tagMinKeyElement.fieldName(), tagMaxKeyElement.fieldName()));
+ tagMinKeyElement.fieldNameStringData() ==
+ tagMaxKeyElement.fieldNameStringData());
BSONElement proposedKeyElement = proposedFields.next();
- bool match =
- (str::equals(tagMinKeyElement.fieldName(), proposedKeyElement.fieldName()) &&
- ((tagMinFields.more() && proposedFields.more()) ||
- (!tagMinFields.more() && !proposedFields.more())));
+ bool match = ((tagMinKeyElement.fieldNameStringData() ==
+ proposedKeyElement.fieldNameStringData()) &&
+ ((tagMinFields.more() && proposedFields.more()) ||
+ (!tagMinFields.more() && !proposedFields.more())));
uassert(ErrorCodes::InvalidOptions,
str::stream() << "the proposed shard key " << proposedKey.toString()
<< " does not match with the shard key of the existing zone "