Use string_view instead of copy whole string.

This commit is contained in:
RadWolfie 2021-04-15 17:40:25 -05:00
parent 11ac2f8058
commit 4778aeab1e
2 changed files with 6 additions and 6 deletions

View File

@ -609,18 +609,18 @@ int CxbxDeviceIndexByHostPath(const char * HostDevicePath)
return -1;
}
XboxDevice *CxbxDeviceByDevicePath(const std::string XboxDevicePath)
XboxDevice *CxbxDeviceByDevicePath(const std::string_view XboxDevicePath)
{
int DeviceIndex = CxbxDeviceIndexByDevicePath(XboxDevicePath.c_str());
int DeviceIndex = CxbxDeviceIndexByDevicePath(XboxDevicePath.data());
if (DeviceIndex >= 0)
return &Devices[DeviceIndex];
return nullptr;
}
XboxDevice *CxbxDeviceByHostPath(const std::string HostDevicePath)
XboxDevice *CxbxDeviceByHostPath(const std::string_view HostDevicePath)
{
int DeviceIndex = CxbxDeviceIndexByHostPath(HostDevicePath.c_str());
int DeviceIndex = CxbxDeviceIndexByHostPath(HostDevicePath.data());
if (DeviceIndex >= 0)
return &Devices[DeviceIndex];

View File

@ -220,8 +220,8 @@ CHAR* NtStatusToString(IN NTSTATUS Status);
int CxbxRegisterDeviceHostPath(std::string_view XboxFullPath, std::string HostDevicePath, bool IsFile = false);
int CxbxDeviceIndexByDevicePath(const char *XboxDevicePath);
XboxDevice *CxbxDeviceByDevicePath(const std::string XboxDevicePath);
XboxDevice* CxbxDeviceByHostPath(const std::string HostPath);
XboxDevice *CxbxDeviceByDevicePath(const std::string_view XboxDevicePath);
XboxDevice* CxbxDeviceByHostPath(const std::string_view HostPath);
std::string CxbxConvertXboxToHostPath(const std::string_view XboxDevicePath);
char SymbolicLinkToDriveLetter(std::string aSymbolicLinkName);