diff options
author | Ed Tanous <ed@tanous.net> | 2020-10-15 19:41:17 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2020-10-23 18:29:24 +0300 |
commit | f23b729676559f539790580930b1ff3b0c05805b (patch) | |
tree | c068573cefdfd5e6dff266fc6a9c1e530af9b491 /redfish-core/lib/account_service.hpp | |
parent | 04e438cbad66838724d78ce12f28aff1fb892a63 (diff) | |
download | bmcweb-f23b729676559f539790580930b1ff3b0c05805b.tar.xz |
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
Diffstat (limited to 'redfish-core/lib/account_service.hpp')
-rw-r--r-- | redfish-core/lib/account_service.hpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp index 23c7fb9351..06c6bf2eb9 100644 --- a/redfish-core/lib/account_service.hpp +++ b/redfish-core/lib/account_service.hpp @@ -208,11 +208,11 @@ inline void parseLDAPConfigData(nlohmann::json& json_response, 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 @@ inline void handleRoleMapPatch( 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 @@ class AccountService : public Node if (remoteRoleMapData) { - std::vector<nlohmann::json> remoteRoleMap = - std::move(*remoteRoleMapData); - handleRoleMapPatch(asyncResp, confData.groupRoleList, - serverT, remoteRoleMap); + serverT, *remoteRoleMapData); } }); } @@ -1367,7 +1368,7 @@ class AccountsCollection : public Node { 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 @@ class AccountsCollection : public Node } 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 @@ class ManagerAccount : public Node } 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 @@ class ManagerAccount : public Node 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 @@ class ManagerAccount : public Node 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( |