summaryrefslogtreecommitdiff
path: root/src/input_common/udp/client.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2020-02-03 09:24:03 -0500
committerGravatar Lioncash2020-02-03 09:24:05 -0500
commit5c61e0ba3938c9b939416ec996ee339bf1417ebf (patch)
tree0fa2eb2fa1f0b628f7dacbd356408f724e51c397 /src/input_common/udp/client.cpp
parentinput_common/udp: std::move shared_ptr within Client constructor (diff)
downloadyuzu-5c61e0ba3938c9b939416ec996ee339bf1417ebf.tar.gz
yuzu-5c61e0ba3938c9b939416ec996ee339bf1417ebf.tar.xz
yuzu-5c61e0ba3938c9b939416ec996ee339bf1417ebf.zip
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.
Diffstat (limited to 'src/input_common/udp/client.cpp')
-rw-r--r--src/input_common/udp/client.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/input_common/udp/client.cpp b/src/input_common/udp/client.cpp
index 1fa246e79..2228571a6 100644
--- a/src/input_common/udp/client.cpp
+++ b/src/input_common/udp/client.cpp
@@ -206,7 +206,7 @@ void TestCommunication(const std::string& host, u16 port, u8 pad_index, u32 clie
206 Common::Event success_event; 206 Common::Event success_event;
207 SocketCallback callback{[](Response::Version version) {}, [](Response::PortInfo info) {}, 207 SocketCallback callback{[](Response::Version version) {}, [](Response::PortInfo info) {},
208 [&](Response::PadData data) { success_event.Set(); }}; 208 [&](Response::PadData data) { success_event.Set(); }};
209 Socket socket{host, port, pad_index, client_id, callback}; 209 Socket socket{host, port, pad_index, client_id, std::move(callback)};
210 std::thread worker_thread{SocketLoop, &socket}; 210 std::thread worker_thread{SocketLoop, &socket};
211 bool result = success_event.WaitFor(std::chrono::seconds(8)); 211 bool result = success_event.WaitFor(std::chrono::seconds(8));
212 socket.Stop(); 212 socket.Stop();
@@ -266,7 +266,7 @@ CalibrationConfigurationJob::CalibrationConfigurationJob(
266 complete_event.Set(); 266 complete_event.Set();
267 } 267 }
268 }}; 268 }};
269 Socket socket{host, port, pad_index, client_id, callback}; 269 Socket socket{host, port, pad_index, client_id, std::move(callback)};
270 std::thread worker_thread{SocketLoop, &socket}; 270 std::thread worker_thread{SocketLoop, &socket};
271 complete_event.Wait(); 271 complete_event.Wait();
272 socket.Stop(); 272 socket.Stop();