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/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 23c7fb9..06c6bf2 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -208,11 +208,11 @@
inline void handleRoleMapPatch(
const std::shared_ptr<AsyncResp>& asyncResp,
const std::vector<std::pair<std::string, LDAPRoleMapData>>& roleMapObjData,
- const std::string& serverType, std::vector<nlohmann::json>& input)
+ const std::string& serverType, const std::vector<nlohmann::json>& input)
{
for (size_t index = 0; index < input.size(); index++)
{
- nlohmann::json& thisJson = input[index];
+ const nlohmann::json& thisJson = input[index];
if (thisJson.is_null())
{
@@ -255,8 +255,12 @@
std::optional<std::string> remoteGroup;
std::optional<std::string> localRole;
- if (!json_util::readJson(thisJson, asyncResp->res, "RemoteGroup",
- remoteGroup, "LocalRole", localRole))
+ // This is a copy, but it's required in this case because of how
+ // readJson is structured
+ nlohmann::json thisJsonCopy = thisJson;
+ if (!json_util::readJson(thisJsonCopy, asyncResp->res,
+ "RemoteGroup", remoteGroup, "LocalRole",
+ localRole))
{
continue;
}
@@ -1112,11 +1116,8 @@
if (remoteRoleMapData)
{
- std::vector<nlohmann::json> remoteRoleMap =
- std::move(*remoteRoleMapData);
-
handleRoleMapPatch(asyncResp, confData.groupRoleList,
- serverT, remoteRoleMap);
+ serverT, *remoteRoleMapData);
}
});
}
@@ -1367,7 +1368,7 @@
{
const std::string& path =
static_cast<const std::string&>(user.first);
- std::size_t lastIndex = path.rfind("/");
+ std::size_t lastIndex = path.rfind('/');
if (lastIndex == std::string::npos)
{
lastIndex = 0;
@@ -1453,9 +1454,9 @@
}
crow::connections::systemBus->async_method_call(
- [asyncResp, username, password{std::move(password)}](
- const boost::system::error_code ec2,
- sdbusplus::message::message& m) {
+ [asyncResp, username,
+ password](const boost::system::error_code ec2,
+ sdbusplus::message::message& m) {
if (ec2)
{
userErrorMessageHandler(m.get_error(), asyncResp,
@@ -1733,10 +1734,10 @@
}
crow::connections::systemBus->async_method_call(
[this, asyncResp, username, password(std::move(password)),
- roleId(std::move(roleId)), enabled(std::move(enabled)),
+ roleId(std::move(roleId)), enabled,
newUser{std::string(*newUserName)},
- locked(std::move(locked))](const boost::system::error_code ec,
- sdbusplus::message::message& m) {
+ locked](const boost::system::error_code ec,
+ sdbusplus::message::message& m) {
if (ec)
{
userErrorMessageHandler(m.get_error(), asyncResp, newUser,
@@ -1765,9 +1766,8 @@
dbus::utility::checkDbusPathExists(
dbusObjectPath,
[dbusObjectPath(std::move(dbusObjectPath)), username,
- password(std::move(password)), roleId(std::move(roleId)),
- enabled(std::move(enabled)), locked(std::move(locked)),
- asyncResp{std::move(asyncResp)}](int rc) {
+ password(std::move(password)), roleId(std::move(roleId)), enabled,
+ locked, asyncResp{std::move(asyncResp)}](int rc) {
if (!rc)
{
messages::resourceNotFound(
@@ -1901,8 +1901,8 @@
const std::string userPath = "/xyz/openbmc_project/user/" + params[0];
crow::connections::systemBus->async_method_call(
- [asyncResp, username{std::move(params[0])}](
- const boost::system::error_code ec) {
+ [asyncResp,
+ username{params[0]}](const boost::system::error_code ec) {
if (ec)
{
messages::resourceNotFound(