init: Avoid extra string copies when finding devices by using const refs
Now that FindPlatformDevice() isn't modifying the path argument, and
is just passing it on to FindSubsystemDevice(), take this argument by
const reference. That should avoid an unnecessary string copy.
Bug: 316324155
Test: Compile
Change-Id: I1d92a322d0c311ee46a117dd9d650896ec02520f
diff --git a/init/devices.cpp b/init/devices.cpp
index 4de1e20..2cdecec 100644
--- a/init/devices.cpp
+++ b/init/devices.cpp
@@ -307,7 +307,8 @@
return false;
}
-bool DeviceHandler::FindPlatformDevice(std::string path, std::string* platform_device_path) const {
+bool DeviceHandler::FindPlatformDevice(const std::string& path,
+ std::string* platform_device_path) const {
const std::set<std::string> subsystem_paths = {
sysfs_mount_point_ + "/bus/platform",
sysfs_mount_point_ + "/bus/amba",
@@ -316,7 +317,7 @@
return FindSubsystemDevice(path, platform_device_path, subsystem_paths);
}
-bool DeviceHandler::FindMmcDevice(std::string path, std::string* mmc_device_path) const {
+bool DeviceHandler::FindMmcDevice(const std::string& path, std::string* mmc_device_path) const {
const std::set<std::string> subsystem_paths = {
sysfs_mount_point_ + "/bus/mmc",
};
@@ -324,7 +325,7 @@
return FindSubsystemDevice(path, mmc_device_path, subsystem_paths);
}
-bool DeviceHandler::FindScsiDevice(std::string path, std::string* scsi_device_path) const {
+bool DeviceHandler::FindScsiDevice(const std::string& path, std::string* scsi_device_path) const {
const std::set<std::string> subsystem_paths = {
sysfs_mount_point_ + "/bus/scsi",
};