input_common/main: Pass MappingData by const reference in callbacks

Avoids creating unnecessary 168 byte copies per callback invocation.
This commit is contained in:
Lioncash 2022-01-24 11:31:40 -05:00
parent 2136ebccd6
commit 51dd3da11c
2 changed files with 3 additions and 3 deletions

View file

@ -89,7 +89,7 @@ struct UpdateCallback {
// Triggered if data changed on the controller and the engine is on configuring mode // Triggered if data changed on the controller and the engine is on configuring mode
struct MappingCallback { struct MappingCallback {
std::function<void(MappingData)> on_data; std::function<void(const MappingData&)> on_data;
}; };
// Input Identifier of data source // Input Identifier of data source

View file

@ -27,7 +27,7 @@ namespace InputCommon {
struct InputSubsystem::Impl { struct InputSubsystem::Impl {
void Initialize() { void Initialize() {
mapping_factory = std::make_shared<MappingFactory>(); mapping_factory = std::make_shared<MappingFactory>();
MappingCallback mapping_callback{[this](MappingData data) { RegisterInput(data); }}; MappingCallback mapping_callback{[this](const MappingData& data) { RegisterInput(data); }};
keyboard = std::make_shared<Keyboard>("keyboard"); keyboard = std::make_shared<Keyboard>("keyboard");
keyboard->SetMappingCallback(mapping_callback); keyboard->SetMappingCallback(mapping_callback);
@ -284,7 +284,7 @@ struct InputSubsystem::Impl {
#endif #endif
} }
void RegisterInput(MappingData data) { void RegisterInput(const MappingData& data) {
mapping_factory->RegisterInput(data); mapping_factory->RegisterInput(data);
} }