performance: fixup missing const reference in zone
Zone::getSensor is passed directly to the Sensor Manager getSensor which
takes the parameter by reference. Make it use an explicit const
reference at both layers.
Change-Id: I4895ea2935d20b73b88d33972e44b9ac557cd988
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/pid/zone.cpp b/pid/zone.cpp
index 0c9718a..b1da7ec 100644
--- a/pid/zone.cpp
+++ b/pid/zone.cpp
@@ -324,7 +324,7 @@
}
}
-Sensor* PIDZone::getSensor(std::string name)
+Sensor* PIDZone::getSensor(const std::string& name)
{
return _mgr.getSensor(name);
}
diff --git a/pid/zone.hpp b/pid/zone.hpp
index 3e2166c..6db7b7e 100644
--- a/pid/zone.hpp
+++ b/pid/zone.hpp
@@ -31,7 +31,7 @@
virtual float getMaxRPMRequest() const = 0;
virtual bool getFailSafeMode() const = 0;
virtual float getFailSafePercent() const = 0;
- virtual Sensor* getSensor(std::string name) = 0;
+ virtual Sensor* getSensor(const std::string& name) = 0;
};
/*
@@ -68,7 +68,7 @@
float getFailSafePercent(void) const override;
float getMinThermalRpmSetPt(void) const;
- Sensor* getSensor(std::string name) override;
+ Sensor* getSensor(const std::string& name) override;
void determineMaxRPMRequest(void);
void updateFanTelemetry(void);
void updateSensors(void);
diff --git a/test/zone_mock.hpp b/test/zone_mock.hpp
index 8dbf24a..79947fb 100644
--- a/test/zone_mock.hpp
+++ b/test/zone_mock.hpp
@@ -16,5 +16,5 @@
MOCK_CONST_METHOD0(getMaxRPMRequest, float());
MOCK_CONST_METHOD0(getFailSafeMode, bool());
MOCK_CONST_METHOD0(getFailSafePercent, float());
- MOCK_METHOD1(getSensor, Sensor*(std::string));
+ MOCK_METHOD1(getSensor, Sensor*(const std::string&));
};