Simplify string formatting
These are fairly complex string constructions that clang-tidy flags as a
performance problem. Replace with std::format.
Change-Id: I7f43dc0a87bd5059eca9cf7324f94707ff500ad3
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/dbus/dbusconfiguration.cpp b/dbus/dbusconfiguration.cpp
index 8b18b4f..d86ebde 100644
--- a/dbus/dbusconfiguration.cpp
+++ b/dbus/dbusconfiguration.cpp
@@ -826,11 +826,9 @@
/* all expected inputs in the configuration are expected
* to be sensor interfaces
*/
- throw std::runtime_error(
- "sensor at dbus path [" + inputSensorPath +
- "] has an interface [" + dbusInterface +
- "] that does not match the expected interface of " +
- sensorInterface);
+ throw std::runtime_error(std::format(
+ "sensor at dbus path [{}] has an interface [{}] that does not match the expected interface of {}",
+ inputSensorPath, dbusInterface, sensorInterface));
}
}
@@ -854,12 +852,10 @@
{
/* MissingIsAcceptable same error checking as Inputs
*/
- throw std::runtime_error(
- "sensor at dbus path [" +
- missingAcceptableSensorPath +
- "] has an interface [" + dbusInterface +
- "] that does not match the expected interface of " +
- sensorInterface);
+ throw std::runtime_error(std::format(
+ "sensor at dbus path [{}] has an interface [{}] that does not match the expected interface of {}",
+ missingAcceptableSensorPath, dbusInterface,
+ sensorInterface));
}
}
@@ -916,12 +912,9 @@
}
if (defaultPwmInterface != pwmInterface)
{
- throw std::runtime_error(
- "fan pwm control at dbus path [" + pwmPath +
- "] has an interface [" + pwmInterface +
- "] that does not match the expected interface "
- "of " +
- defaultPwmInterface);
+ throw std::runtime_error(std::format(
+ "fan pwm control at dbus path [{}] has an interface [{}] that does not match the expected interface of {}",
+ pwmPath, pwmInterface, defaultPwmInterface));
}
const std::string& fanPath =
inputSensorInterfaces.at(idx).first;