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/sensors.hpp b/redfish-core/lib/sensors.hpp
index 6480861..567cb0c 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -388,7 +388,7 @@
std::string chassisName;
for (const std::string& chassis : chassisPaths)
{
- std::size_t lastPos = chassis.rfind("/");
+ std::size_t lastPos = chassis.rfind('/');
if (lastPos == std::string::npos)
{
BMCWEB_LOG_ERROR << "Failed to find '/' in " << chassis;
@@ -441,7 +441,7 @@
std::string chassisName;
for (const std::string& chassis : chassisPaths)
{
- std::size_t lastPos = chassis.rfind("/");
+ std::size_t lastPos = chassis.rfind('/');
if (lastPos == std::string::npos)
{
BMCWEB_LOG_ERROR << "Failed to find '/' in " << chassis;
@@ -1149,7 +1149,7 @@
sensorsAsyncResp->res);
return;
}
- size_t lastSlash = path.rfind("/");
+ size_t lastSlash = path.rfind('/');
if (lastSlash == std::string::npos)
{
// this should be impossible
@@ -1180,7 +1180,7 @@
sensorsAsyncResp->res.jsonValue["Fans"];
for (const std::string& item : *collection)
{
- lastSlash = item.rfind("/");
+ lastSlash = item.rfind('/');
// make a copy as collection is const
std::string itemName =
item.substr(lastSlash + 1);
@@ -2617,13 +2617,13 @@
auto getInventoryItemsCb =
[SensorsAsyncResp, sensorNames, connections,
objectMgrPaths](
- std::shared_ptr<std::vector<InventoryItem>>
+ const std::shared_ptr<std::vector<InventoryItem>>&
inventoryItems) {
BMCWEB_LOG_DEBUG << "getInventoryItemsCb enter";
// Get sensor data and store results in JSON
getSensorData(SensorsAsyncResp, sensorNames,
connections, objectMgrPaths,
- std::move(inventoryItems));
+ inventoryItems);
BMCWEB_LOG_DEBUG << "getInventoryItemsCb exit";
};
@@ -2657,10 +2657,10 @@
BMCWEB_LOG_DEBUG << "getChassisData enter";
auto getChassisCb =
[SensorsAsyncResp](
- std::shared_ptr<boost::container::flat_set<std::string>>
+ const std::shared_ptr<boost::container::flat_set<std::string>>&
sensorNames) {
BMCWEB_LOG_DEBUG << "getChassisCb enter";
- processSensorList(SensorsAsyncResp, std::move(sensorNames));
+ processSensorList(SensorsAsyncResp, sensorNames);
BMCWEB_LOG_DEBUG << "getChassisCb exit";
};
SensorsAsyncResp->res.jsonValue["Redundancy"] = nlohmann::json::array();
@@ -2686,7 +2686,7 @@
{
for (std::string_view chassisSensor : sensorsList)
{
- std::size_t pos = chassisSensor.rfind("/");
+ std::size_t pos = chassisSensor.rfind('/');
if (pos >= (chassisSensor.size() - 1))
{
continue;
@@ -3042,7 +3042,7 @@
{
BMCWEB_LOG_DEBUG << "Adding sensor: " << sensor;
- std::size_t lastPos = sensor.rfind("/");
+ std::size_t lastPos = sensor.rfind('/');
if (lastPos == std::string::npos ||
lastPos + 1 >= sensor.size())
{
@@ -3129,7 +3129,7 @@
std::vector<std::string>>>>&
object) {
std::string_view sensor = object.first;
- std::size_t lastPos = sensor.rfind("/");
+ std::size_t lastPos = sensor.rfind('/');
if (lastPos == std::string::npos ||
lastPos + 1 >= sensor.size())
{