SERVER-127488 fix single-char StringData::find calls (#54402)
GitOrigin-RevId: 68e4068306280eee5fb3a9063d2217a8366ad5ac
This commit is contained in:
parent
d81e12fc17
commit
0966c1e4b1
@ -77,7 +77,7 @@ std::pair<BSONElement, bool> extractNonArrayElementAtPath(const BSONObj& obj, St
|
||||
static const auto kEmptyElt = BSONElement{};
|
||||
|
||||
auto&& [elt, tail] = [&]() -> std::pair<BSONElement, StringData> {
|
||||
if (auto dotOffset = path.find("."); dotOffset != std::string::npos) {
|
||||
if (auto dotOffset = path.find('.'); dotOffset != std::string::npos) {
|
||||
return {obj.getField(path.substr(0, dotOffset)), path.substr(dotOffset + 1)};
|
||||
}
|
||||
return {obj.getField(path), ""_sd};
|
||||
|
||||
@ -294,7 +294,7 @@ Test Test::parseTest(std::fstream& fs,
|
||||
} else {
|
||||
auto sd = StringData{lineFromFile};
|
||||
{
|
||||
auto endDocument = sd.rfind("}");
|
||||
auto endDocument = sd.rfind('}');
|
||||
if (endDocument == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
@ -303,7 +303,7 @@ Test Test::parseTest(std::fstream& fs,
|
||||
sd.remove_suffix(sd.size() - endDocument - 1);
|
||||
}
|
||||
{
|
||||
auto startDocument = sd.find("{");
|
||||
auto startDocument = sd.find('{');
|
||||
if (startDocument == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -264,7 +264,7 @@ void processSampledDiffs(OperationContext* opCtx,
|
||||
|
||||
size_t startIndex = 0;
|
||||
while (startIndex < shardKeyFieldName.size()) {
|
||||
const size_t lastDotIndex = shardKeyFieldName.find(".", startIndex);
|
||||
const size_t lastDotIndex = shardKeyFieldName.find('.', startIndex);
|
||||
if (lastDotIndex == std::string::npos) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ Status validateClusteredIndexSpec(OperationContext* opCtx,
|
||||
}
|
||||
|
||||
const auto arbitraryClusterKeyField = clustered_util::getClusterKeyFieldName(spec);
|
||||
if (arbitraryClusterKeyField.find(".", 0) != std::string::npos) {
|
||||
if (arbitraryClusterKeyField.find('.', 0) != std::string::npos) {
|
||||
return Status(
|
||||
ErrorCodes::Error(6053701),
|
||||
"The clusteredIndex option does not support a cluster key with nested fields");
|
||||
|
||||
@ -513,7 +513,7 @@ std::string Decimal128::toString() const {
|
||||
|
||||
StringData dec128String(decimalCharRepresentation);
|
||||
|
||||
int ePos = dec128String.find("E");
|
||||
int ePos = dec128String.find('E');
|
||||
|
||||
// Calculate the precision and exponent of the number and output it in a readable manner
|
||||
int precision = 0;
|
||||
|
||||
@ -179,7 +179,7 @@ bool matchesGoogleFilter(StringData filt, StringData suite, StringData test) {
|
||||
filt.remove_prefix(1);
|
||||
continue;
|
||||
}
|
||||
size_t pos = filt.find_first_of(":");
|
||||
size_t pos = filt.find_first_of(':');
|
||||
StringData elem = filt.substr(0, pos);
|
||||
filt = filt.substr(pos);
|
||||
if (matchesGooglePattern(elem, fullName))
|
||||
|
||||
@ -644,7 +644,7 @@ HostAndPort exactHostAndPortFromUrl(StringData url) {
|
||||
|
||||
url = url.substr(slashesIndex + slashes.size());
|
||||
if (url.find('/') != std::string::npos) {
|
||||
url = url.substr(0, url.find("/"));
|
||||
url = url.substr(0, url.find('/'));
|
||||
}
|
||||
|
||||
auto hp = HostAndPort(url);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user