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/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index 7ece888..54dafb4 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -156,14 +156,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 -EINVAL;
}
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 -EINVAL;
@@ -247,8 +247,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);
@@ -259,8 +259,8 @@
{"EventType", "Event"},
{"Severity", std::move(severity)},
{"Message", std::move(msg)},
- {"MessageId", std::move(messageID)},
- {"MessageArgs", std::move(messageArgs)},
+ {"MessageId", messageID},
+ {"MessageArgs", messageArgs},
{"EventTimestamp", std::move(timestamp)},
{"Context", customText}};
return 0;
@@ -1122,7 +1122,7 @@
std::string logEntry;
while (std::getline(logStream, logEntry))
{
- size_t space = logEntry.find_first_of(" ");
+ size_t space = logEntry.find_first_of(' ');
if (space == std::string::npos)
{
// Shouldn't enter here but lets skip it.
@@ -1346,7 +1346,7 @@
void getMetricReading(const std::string& service,
const std::string& objPath, const std::string& intf)
{
- std::size_t found = objPath.find_last_of("/");
+ std::size_t found = objPath.find_last_of('/');
if (found == std::string::npos)
{
BMCWEB_LOG_DEBUG << "Invalid objPath received";
diff --git a/redfish-core/include/server_sent_events.hpp b/redfish-core/include/server_sent_events.hpp
index ee4ad4d..578fa19 100644
--- a/redfish-core/include/server_sent_events.hpp
+++ b/redfish-core/include/server_sent_events.hpp
@@ -261,8 +261,8 @@
ServerSentEvents& operator=(ServerSentEvents&&) = delete;
ServerSentEvents(const std::shared_ptr<boost::beast::tcp_stream>& adaptor) :
- sseConn(std::move(adaptor)), state(SseConnState::startInit),
- retryCount(0), maxRetryAttempts(5)
+ sseConn(adaptor), state(SseConnState::startInit), retryCount(0),
+ maxRetryAttempts(5)
{
startSSE();
}
diff --git a/redfish-core/include/utils/collection.hpp b/redfish-core/include/utils/collection.hpp
index e73fce3..85a462a 100644
--- a/redfish-core/include/utils/collection.hpp
+++ b/redfish-core/include/utils/collection.hpp
@@ -44,7 +44,7 @@
for (const auto& object : subtree)
{
- auto iter = object.first.rfind("/");
+ auto iter = object.first.rfind('/');
if ((iter != std::string::npos) && (iter < object.first.size()))
{
members.push_back(
diff --git a/redfish-core/include/utils/fw_utils.hpp b/redfish-core/include/utils/fw_utils.hpp
index 6a2ca14..43eded6 100644
--- a/redfish-core/include/utils/fw_utils.hpp
+++ b/redfish-core/include/utils/fw_utils.hpp
@@ -69,7 +69,7 @@
for (auto& fw : *functionalFw)
{
- std::string::size_type idPos = fw.rfind("/");
+ std::string::size_type idPos = fw.rfind('/');
if (idPos == std::string::npos)
{
BMCWEB_LOG_DEBUG << "Can't parse firmware ID!";
@@ -110,7 +110,7 @@
subtree)
{
// if can't parse fw id then return
- std::string::size_type idPos = obj.first.rfind("/");
+ std::string::size_type idPos = obj.first.rfind('/');
if (idPos == std::string::npos)
{
messages::internalError(aResp->res);