From 575ab92a760f453111b91646049872feef9862e8 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 3 Feb 2020 09:24:03 -0500 Subject: [PATCH] input_common/udp: std::move SocketCallback instances where applicable std::function is allowed to heap allocate if the size of the captures associated with each lambda exceed a certain threshold. This prevents potentially unnecessary reallocations from occurring. --- src/input_common/udp/client.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/input_common/udp/client.cpp b/src/input_common/udp/client.cpp index b6946d9dc..c9ffe899c 100644 --- a/src/input_common/udp/client.cpp +++ b/src/input_common/udp/client.cpp @@ -207,7 +207,7 @@ void TestCommunication(const std::string& host, u16 port, u8 pad_index, u32 clie Common::Event success_event; SocketCallback callback{[](Response::Version version) {}, [](Response::PortInfo info) {}, [&](Response::PadData data) { success_event.Set(); }}; - Socket socket{host, port, pad_index, client_id, callback}; + Socket socket{host, port, pad_index, client_id, std::move(callback)}; std::thread worker_thread{SocketLoop, &socket}; bool result = success_event.WaitFor(std::chrono::seconds(8)); socket.Stop(); @@ -263,7 +263,7 @@ CalibrationConfigurationJob::CalibrationConfigurationJob( complete_event.Set(); } }}; - Socket socket{host, port, pad_index, client_id, callback}; + Socket socket{host, port, pad_index, client_id, std::move(callback)}; std::thread worker_thread{SocketLoop, &socket}; complete_event.Wait(); socket.Stop();