From 564d970bd081571bb648077a32d2a6daa982673c Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 22 May 2024 13:07:13 -0700 Subject: [PATCH] init: Use std::string_view instead of std::string where appropriate Slightly reduce the time that is required to start the init process by changing two static std::string variables into std::string_view variables. Change-Id: Ib683a603da5f3d8968b26453b12544fed8a6397f Signed-off-by: Bart Van Assche --- init/devices.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/init/devices.cpp b/init/devices.cpp index e76786a6d..792d8c843 100644 --- a/init/devices.cpp +++ b/init/devices.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -377,8 +378,8 @@ std::vector DeviceHandler::GetBlockDeviceSymlinks(const Uevent& uev if (FindPlatformDevice(uevent.path, &device)) { // Skip /devices/platform or /devices/ if present - static const std::string devices_platform_prefix = "/devices/platform/"; - static const std::string devices_prefix = "/devices/"; + static constexpr std::string_view devices_platform_prefix = "/devices/platform/"; + static constexpr std::string_view devices_prefix = "/devices/"; if (StartsWith(device, devices_platform_prefix)) { device = device.substr(devices_platform_prefix.length());