diff options
author | Lioncash <mathew1800@gmail.com> | 2021-12-13 21:09:28 -0500 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2021-12-13 21:22:02 -0500 |
commit | e05d2a70b24e550d67fcdd24aae7094ad41745f8 (patch) | |
tree | af5116d02b99366344c261df03cae992b2e96ae5 /src/common/input.h | |
parent | 54eafbaf172309d92c6b2c5069de23fc534dd2d2 (diff) |
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.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/common/input.h b/src/common/input.h index 848ad7b811..f775a4c011 100644 --- a/src/common/input.h +++ b/src/common/input.h @@ -227,7 +227,7 @@ struct CallbackStatus { // Triggered once every input change struct InputCallback { - std::function<void(CallbackStatus)> on_change; + std::function<void(const CallbackStatus&)> on_change; }; /// An abstract class template for an input device (a button, an analog input, etc.). @@ -247,7 +247,7 @@ public: } // Triggers the function set in the callback - void TriggerOnChange(CallbackStatus status) { + void TriggerOnChange(const CallbackStatus& status) { if (callback.on_change) { callback.on_change(status); } |