Skip to content
Permalink
Browse files

ControllerInterface/Device: Take vector by const reference in DetectI…

…nput()

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.
  • Loading branch information...
lioncash committed May 29, 2019
1 parent 246e2a7 commit 27346fee8a5466503f32493510da98846f2efb01
@@ -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<std::shared_ptr<Device>, Device::Input*>
DeviceContainer::DetectInput(u32 wait_ms, std::vector<std::string> device_strings)
DeviceContainer::DetectInput(u32 wait_ms, const std::vector<std::string>& device_strings)
{
struct InputState
{
@@ -273,7 +273,7 @@ DeviceContainer::DetectInput(u32 wait_ms, std::vector<std::string> device_string

// Acquire devices and initial input states.
std::vector<DeviceState> device_states;
for (auto& device_string : device_strings)
for (const auto& device_string : device_strings)
{
DeviceQualifier dq;
dq.FromString(device_string);
@@ -188,7 +188,7 @@ class DeviceContainer
bool HasConnectedDevice(const DeviceQualifier& qualifier) const;

std::pair<std::shared_ptr<Device>, Device::Input*>
DetectInput(u32 wait_ms, std::vector<std::string> device_strings);
DetectInput(u32 wait_ms, const std::vector<std::string>& device_strings);

protected:
mutable std::mutex m_devices_mutex;

0 comments on commit 27346fe

Please sign in to comment.
You can’t perform that action at this time.