Using reference to avoid copy
With this commit a reference will be used during some structure
binding to avoid copies.
Tested:
CPUSensors and PSUSensors launched on physical machine, no
regression detected.
Signed-off-by: Zbigniew Kurzynski <zbigniew.kurzynski@intel.com>
Change-Id: I7aa270e440e9aadeca151acc6d9b73d7c4c4f40c
diff --git a/src/CPUSensor.cpp b/src/CPUSensor.cpp
index 684c430..2356821 100644
--- a/src/CPUSensor.cpp
+++ b/src/CPUSensor.cpp
@@ -56,7 +56,7 @@
{
if (auto fileParts = splitFileName(path))
{
- auto [type, nr, item] = *fileParts;
+ auto& [type, nr, item] = *fileParts;
std::string interfacePath;
if (type.compare("power") == 0)
{
@@ -162,13 +162,13 @@
if (auto fileParts = splitFileName(path))
{
- auto [fileType, fileNr, fileItem] = *fileParts;
+ auto& [fileType, fileNr, fileItem] = *fileParts;
const auto mapIt = map.find(fileItem);
if (mapIt != map.cend())
{
for (const auto& vectorItem : mapIt->second)
{
- auto [suffix, oldValue, dbusName] = vectorItem;
+ auto& [suffix, oldValue, dbusName] = vectorItem;
auto attrPath = boost::replace_all_copy(path, fileItem, suffix);
if (auto newVal =
readFile(attrPath, CPUSensor::sensorScaleFactor))