Replace boost starts_with/ends_with with std::string
C++20 introduces std::string::starts_with and std::string::ends_with,
which provide standard, efficient, and header-light ways to check
string prefixes and suffixes. Replacing boost::algorithm::starts_with
and boost::algorithm::ends_with reduces Boost dependencies,
simplifies includes, and improves compilation performance.
Change-Id: I611ccb49a174dcd5433c1001cf1750907dd023ac
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
diff --git a/dbus-sdr/sdrutils.cpp b/dbus-sdr/sdrutils.cpp
index 7bfa1ed..0fd14c9 100644
--- a/dbus-sdr/sdrutils.cpp
+++ b/dbus-sdr/sdrutils.cpp
@@ -185,8 +185,8 @@
for (const auto& sensor : ipmi::sensor::sensors)
{
// Threshold sensors should not be emplaced in here.
- if (boost::starts_with(sensor.second.sensorPath,
- "/xyz/openbmc_project/sensors/"))
+ if (sensor.second.sensorPath.starts_with(
+ "/xyz/openbmc_project/sensors/"))
{
continue;
}
@@ -493,8 +493,7 @@
for (const auto& entry : entityManagerService->second)
{
- if (boost::algorithm::starts_with(entry,
- "xyz.openbmc_project.Configuration."))
+ if (entry.starts_with("xyz.openbmc_project.Configuration."))
{
return &entry;
}
diff --git a/dbus-sdr/sensorcommands.cpp b/dbus-sdr/sensorcommands.cpp
index f3b1720..06d039a 100644
--- a/dbus-sdr/sensorcommands.cpp
+++ b/dbus-sdr/sensorcommands.cpp
@@ -521,7 +521,7 @@
#ifdef SHORTNAME_REMOVE_SUFFIX
for (const auto& suffix : suffixes)
{
- if (boost::ends_with(name, suffix))
+ if (name.ends_with(suffix))
{
boost::replace_all(name, suffix, "");
break;
diff --git a/dbus-sdr/storagecommands.cpp b/dbus-sdr/storagecommands.cpp
index 8bdb7bd..f0c43c3 100644
--- a/dbus-sdr/storagecommands.cpp
+++ b/dbus-sdr/storagecommands.cpp
@@ -740,8 +740,7 @@
dynamic_sensors::ipmi::sel::selLogDir))
{
std::string filename = dirEnt.path().filename();
- if (boost::starts_with(filename,
- dynamic_sensors::ipmi::sel::selLogFilename))
+ if (filename.starts_with(dynamic_sensors::ipmi::sel::selLogFilename))
{
// If we find an ipmi_sel log file, save the path
selLogFiles.emplace_back(
diff --git a/include/dbus-sdr/sdrutils.hpp b/include/dbus-sdr/sdrutils.hpp
index 9d36a50..23d7119 100644
--- a/include/dbus-sdr/sdrutils.hpp
+++ b/include/dbus-sdr/sdrutils.hpp
@@ -14,7 +14,6 @@
// limitations under the License.
*/
-#include <boost/algorithm/string.hpp>
#include <boost/bimap.hpp>
#include <boost/container/flat_map.hpp>
#include <ipmid/api.hpp>
diff --git a/ipmid-new.cpp b/ipmid-new.cpp
index 0b3e389..23a8399 100644
--- a/ipmid-new.cpp
+++ b/ipmid-new.cpp
@@ -19,7 +19,6 @@
#include <dlfcn.h>
-#include <boost/algorithm/string.hpp>
#include <boost/asio/detached.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/spawn.hpp>
@@ -437,7 +436,7 @@
if (!oldOwner.empty())
{
- if (boost::starts_with(oldOwner, ":"))
+ if (oldOwner.starts_with(":"))
{
// Connection removed
auto it = uniqueNameToChannelNumber.find(oldOwner);