summaryrefslogtreecommitdiff
path: root/src/common/input.h
diff options
context:
space:
mode:
authorGravatar Lioncash2021-12-13 21:09:28 -0500
committerGravatar Lioncash2021-12-13 21:22:02 -0500
commite05d2a70b24e550d67fcdd24aae7094ad41745f8 (patch)
treeaf5116d02b99366344c261df03cae992b2e96ae5 /src/common/input.h
parentcommon/input: Remove unnecessary returns (diff)
downloadyuzu-e05d2a70b24e550d67fcdd24aae7094ad41745f8.tar.gz
yuzu-e05d2a70b24e550d67fcdd24aae7094ad41745f8.tar.xz
yuzu-e05d2a70b24e550d67fcdd24aae7094ad41745f8.zip
common/input: Avoid numerous large copies of CallbackStatus
CallbackStatus instances aren't the cheapest things to copy around (relative to everything else), given that they're currently 520 bytes in size and are currently copied numerous times when callbacks are invoked. Instead, we can pass the status by const reference to avoid all the copying.
Diffstat (limited to 'src/common/input.h')
-rw-r--r--src/common/input.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/common/input.h b/src/common/input.h
index 848ad7b81..f775a4c01 100644
--- a/src/common/input.h
+++ b/src/common/input.h
@@ -227,7 +227,7 @@ struct CallbackStatus {
227 227
228// Triggered once every input change 228// Triggered once every input change
229struct InputCallback { 229struct InputCallback {
230 std::function<void(CallbackStatus)> on_change; 230 std::function<void(const CallbackStatus&)> on_change;
231}; 231};
232 232
233/// An abstract class template for an input device (a button, an analog input, etc.). 233/// An abstract class template for an input device (a button, an analog input, etc.).
@@ -247,7 +247,7 @@ public:
247 } 247 }
248 248
249 // Triggers the function set in the callback 249 // Triggers the function set in the callback
250 void TriggerOnChange(CallbackStatus status) { 250 void TriggerOnChange(const CallbackStatus& status) {
251 if (callback.on_change) { 251 if (callback.on_change) {
252 callback.on_change(status); 252 callback.on_change(status);
253 } 253 }