Turn on ALL perf checks
1st, alphabetize the tidy-list for good housekeeping.
Next, enable all the clang-tidy performance checks, and resolve all the
issues. most of the issues boil down to:
1. Using std::move on const variables. This does nothing.
2. Passing big variables (like std::string) by value.
3. Using double quotes on a find call, which constructs an intermediate
string, rather than using the character overload.
Tested
Loaded on system, logged in successfully and pulled down webui-vue. No
new errors.
Walked the Redfish tree a bit, and observed no new problems.
Ran redfish service validator. Got no new failures (although there are
a lot of log service deprecation warnings that we should look at).
Signed-off-by: Ed Tanous <ed@tanous.net>
Change-Id: I2238958c4b22c1e554e09a0a1787c744bdbca43e
diff --git a/http/routing.hpp b/http/routing.hpp
index 9c6a15b..d547348 100644
--- a/http/routing.hpp
+++ b/http/routing.hpp
@@ -30,7 +30,7 @@
class BaseRule
{
public:
- BaseRule(std::string thisRule) : rule(std::move(thisRule))
+ BaseRule(const std::string& thisRule) : rule(thisRule)
{}
virtual ~BaseRule() = default;
@@ -313,7 +313,7 @@
using self_t = WebSocketRule;
public:
- WebSocketRule(std::string ruleIn) : BaseRule(std::move(ruleIn))
+ WebSocketRule(const std::string& ruleIn) : BaseRule(ruleIn)
{}
void validate() override
@@ -402,10 +402,10 @@
return *p;
}
- self_t& name(const std::string& name) noexcept
+ self_t& name(const std::string_view name) noexcept
{
self_t* self = static_cast<self_t*>(this);
- self->nameStr = std::move(name);
+ self->nameStr = name;
return *self;
}
@@ -448,7 +448,7 @@
class DynamicRule : public BaseRule, public RuleParameterTraits<DynamicRule>
{
public:
- DynamicRule(std::string ruleIn) : BaseRule(std::move(ruleIn))
+ DynamicRule(const std::string& ruleIn) : BaseRule(ruleIn)
{}
void validate() override
@@ -521,7 +521,7 @@
public:
using self_t = TaggedRule<Args...>;
- TaggedRule(const std::string& ruleIn) : BaseRule(std::move(ruleIn))
+ TaggedRule(const std::string& ruleIn) : BaseRule(ruleIn)
{}
void validate() override
@@ -612,9 +612,9 @@
}
template <typename Func>
- void operator()(const std::string& name, Func&& f)
+ void operator()(const std::string_view name, Func&& f)
{
- nameStr = std::move(name);
+ nameStr = name;
(*this).template operator()<Func>(std::forward(f));
}