summaryrefslogtreecommitdiff
path: root/redfish-core/lib/sensors.hpp
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2020-10-15 19:41:17 +0300
committerEd Tanous <ed@tanous.net>2020-10-23 18:29:24 +0300
commitf23b729676559f539790580930b1ff3b0c05805b (patch)
treec068573cefdfd5e6dff266fc6a9c1e530af9b491 /redfish-core/lib/sensors.hpp
parent04e438cbad66838724d78ce12f28aff1fb892a63 (diff)
downloadbmcweb-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/sensors.hpp')
-rw-r--r--redfish-core/lib/sensors.hpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 6480861ab7..567cb0ca2d 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -388,7 +388,7 @@ void getValidChassisPath(const std::shared_ptr<SensorsAsyncResp>& asyncResp,
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 @@ void getChassis(const std::shared_ptr<SensorsAsyncResp>& sensorsAsyncResp,
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 @@ inline void populateFanRedundancy(
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 @@ inline void populateFanRedundancy(
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 @@ inline void processSensorList(
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 @@ inline void
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 @@ inline bool findSensorNameUsingSensorPath(
{
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 @@ class SensorCollection : public Node
{
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 @@ class Sensor : public Node
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())
{