SERVER-90577 Enable tidy check performance-inefficient-string-concatenation (#22270)
GitOrigin-RevId: e163558464d2dcde48e6c448167b9c552f691f6b
This commit is contained in:
parent
25cc396e42
commit
b80f31ea08
@ -66,6 +66,7 @@ Checks: '-*,
|
||||
performance-for-range-copy,
|
||||
performance-implicit-conversion-in-loop,
|
||||
performance-inefficient-algorithm,
|
||||
performance-inefficient-string-concatenation,
|
||||
performance-move-constructor-init,
|
||||
performance-no-automatic-move,
|
||||
performance-trivially-destructible,
|
||||
@ -120,7 +121,6 @@ Checks: '-*,
|
||||
-modernize-use-emplace,
|
||||
-modernize-use-noexcept,
|
||||
-modernize-use-uncaught-exceptions,
|
||||
-performance-inefficient-string-concatenation,
|
||||
-performance-inefficient-vector-operation,
|
||||
-performance-unnecessary-value-param,
|
||||
-readability-delete-null-pointer,
|
||||
|
||||
@ -544,7 +544,7 @@ public:
|
||||
std::string result;
|
||||
for (size_t i = 0; i < errors.size(); ++i) {
|
||||
auto error = errors[i];
|
||||
result = result + error.first + " - " + error.second;
|
||||
result += error.first += " - "s += error.second;
|
||||
if (i != errors.size() - 1) {
|
||||
result += "; ";
|
||||
}
|
||||
|
||||
@ -198,9 +198,10 @@ TEST(ExtractAllElementsAlongPath, NestedObjectWithScalarValue) {
|
||||
TEST(ExtractAllElementsAlongPath, NestedMaxDepthObjectWithScalarValue) {
|
||||
BSONObj obj = BSON("a" << 1);
|
||||
std::string dotted_path = "a";
|
||||
dotted_path.reserve(1 + BSONDepth::getMaxAllowableDepth() * 2);
|
||||
for (uint32_t i = 0; i < BSONDepth::getMaxAllowableDepth(); ++i) {
|
||||
obj = BSON("a" << obj);
|
||||
dotted_path = "a." + dotted_path;
|
||||
dotted_path.insert(0, "a.");
|
||||
}
|
||||
|
||||
BSONElementSet actualElements;
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
#include <boost/optional/optional.hpp>
|
||||
#include <boost/smart_ptr.hpp>
|
||||
#include <cstddef>
|
||||
#include <fmt/format.h>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <ostream>
|
||||
@ -555,9 +556,10 @@ std::unique_ptr<MatchExpression> matchRewriteUpdateDescription(
|
||||
// not need to check whether the predicate matches a missing field in this case.
|
||||
static const std::vector<std::string> oplogFields = {"o.diff.d", "o.$unset"};
|
||||
auto rewrittenEquality = std::make_unique<OrMatchExpression>();
|
||||
using namespace fmt::literals;
|
||||
for (auto&& oplogField : oplogFields) {
|
||||
rewrittenEquality->add(std::make_unique<ExistsMatchExpression>(
|
||||
StringData(oplogField + "." + fieldName)));
|
||||
StringData("{}.{}"_format(oplogField, fieldName))));
|
||||
}
|
||||
return rewrittenEquality;
|
||||
};
|
||||
|
||||
@ -57,6 +57,7 @@
|
||||
#include <cstring>
|
||||
#include <exception>
|
||||
#include <fcntl.h>
|
||||
#include <fmt/format.h>
|
||||
#include <fstream> // IWYU pragma: keep
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
@ -994,7 +995,8 @@ Status addYAMLNodesToEnvironment(const YAML::Node& root,
|
||||
// If this is not a special field name, and we are in a sub object, append our
|
||||
// current fieldName to the selector for the sub object we are traversing
|
||||
else {
|
||||
dottedName = parentPath + '.' + fieldName;
|
||||
using namespace fmt::literals;
|
||||
dottedName = "{}.{}"_format(parentPath, fieldName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user