From 27346fee8a5466503f32493510da98846f2efb01 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 29 May 2019 19:10:50 -0400 Subject: [PATCH] ControllerInterface/Device: Take vector by const reference in DetectInput() The vector is only ever queryied and it's contents aren't modified, so there's no reason to take the vector by value. We can take a constant reference to it to avoid unnecessary allocating. --- Source/Core/InputCommon/ControllerInterface/Device.cpp | 4 ++-- Source/Core/InputCommon/ControllerInterface/Device.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/InputCommon/ControllerInterface/Device.cpp b/Source/Core/InputCommon/ControllerInterface/Device.cpp index 9e29389dae..9fbeae22cf 100644 --- a/Source/Core/InputCommon/ControllerInterface/Device.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Device.cpp @@ -256,7 +256,7 @@ bool DeviceContainer::HasConnectedDevice(const DeviceQualifier& qualifier) const // and also properly handles detection when using "FullAnalogSurface" inputs. // Upon input, return the detected Device and Input, else return nullptrs std::pair, Device::Input*> -DeviceContainer::DetectInput(u32 wait_ms, std::vector device_strings) +DeviceContainer::DetectInput(u32 wait_ms, const std::vector& device_strings) { struct InputState { @@ -273,7 +273,7 @@ DeviceContainer::DetectInput(u32 wait_ms, std::vector device_string // Acquire devices and initial input states. std::vector device_states; - for (auto& device_string : device_strings) + for (const auto& device_string : device_strings) { DeviceQualifier dq; dq.FromString(device_string); diff --git a/Source/Core/InputCommon/ControllerInterface/Device.h b/Source/Core/InputCommon/ControllerInterface/Device.h index b5a8695629..fd947ee654 100644 --- a/Source/Core/InputCommon/ControllerInterface/Device.h +++ b/Source/Core/InputCommon/ControllerInterface/Device.h @@ -188,7 +188,7 @@ public: bool HasConnectedDevice(const DeviceQualifier& qualifier) const; std::pair, Device::Input*> - DetectInput(u32 wait_ms, std::vector device_strings); + DetectInput(u32 wait_ms, const std::vector& device_strings); protected: mutable std::mutex m_devices_mutex;