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/log_services.hpp b/redfish-core/lib/log_services.hpp
index c5b7b9d..04f82f7 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -444,7 +444,7 @@
nlohmann::json& thisEntry = entriesArray.back();
const std::string& path =
static_cast<const std::string&>(object.first);
- std::size_t lastPos = path.rfind("/");
+ std::size_t lastPos = path.rfind('/');
if (lastPos == std::string::npos)
{
continue;
@@ -843,7 +843,7 @@
for (const std::string& path : subTreePaths)
{
- std::size_t pos = path.rfind("/");
+ std::size_t pos = path.rfind('/');
if (pos != std::string::npos)
{
std::string logID = path.substr(pos + 1);
@@ -1072,14 +1072,14 @@
{
// The redfish log format is "<Timestamp> <MessageId>,<MessageArgs>"
// First get the Timestamp
- size_t space = logEntry.find_first_of(" ");
+ size_t space = logEntry.find_first_of(' ');
if (space == std::string::npos)
{
return 1;
}
std::string timestamp = logEntry.substr(0, space);
// Then get the log contents
- size_t entryStart = logEntry.find_first_not_of(" ", space);
+ size_t entryStart = logEntry.find_first_not_of(' ', space);
if (entryStart == std::string::npos)
{
return 1;
@@ -1139,8 +1139,8 @@
// Get the Created time from the timestamp. The log timestamp is in RFC3339
// format which matches the Redfish format except for the fractional seconds
// between the '.' and the '+', so just remove them.
- std::size_t dot = timestamp.find_first_of(".");
- std::size_t plus = timestamp.find_first_of("+");
+ std::size_t dot = timestamp.find_first_of('.');
+ std::size_t plus = timestamp.find_first_of('+');
if (dot != std::string::npos && plus != std::string::npos)
{
timestamp.erase(dot, plus - dot);
@@ -1156,7 +1156,7 @@
{"Id", logEntryID},
{"Message", std::move(msg)},
{"MessageId", std::move(messageID)},
- {"MessageArgs", std::move(messageArgs)},
+ {"MessageArgs", messageArgs},
{"EntryType", "Event"},
{"Severity", std::move(severity)},
{"Created", std::move(timestamp)}};
@@ -2529,7 +2529,7 @@
for (const std::string& objpath : resp)
{
// Get the log ID
- std::size_t lastPos = objpath.rfind("/");
+ std::size_t lastPos = objpath.rfind('/');
if (lastPos == std::string::npos)
{
continue;