From 144ed7a3abffaeb0e6306d29d0e34049211a08dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 20 Dec 2023 19:58:09 +0100 Subject: [PATCH] Reduce memory allocations during controller processing --- Core/ControlMapper.cpp | 4 +--- Core/KeyMap.cpp | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Core/ControlMapper.cpp b/Core/ControlMapper.cpp index 629b1eaca3..06722dde09 100644 --- a/Core/ControlMapper.cpp +++ b/Core/ControlMapper.cpp @@ -268,6 +268,7 @@ bool ControlMapper::UpdatePSPState(const InputMapping &changedMapping, double no // For the PSP's button inputs, we just go through and put the flags together. uint32_t buttonMask = 0; uint32_t changedButtonMask = 0; + std::vector inputMappings; for (int i = 0; i < 32; i++) { uint32_t mask = 1 << i; if (!(mask & CTRL_MASK_USER)) { @@ -281,8 +282,6 @@ bool ControlMapper::UpdatePSPState(const InputMapping &changedMapping, double no } SwapMappingIfEnabled(&mappingBit); - - std::vector inputMappings; if (!KeyMap::InputMappingsFromPspButton(mappingBit, &inputMappings, false)) continue; @@ -316,7 +315,6 @@ bool ControlMapper::UpdatePSPState(const InputMapping &changedMapping, double no // Note that virtual keys include the analog directions, as they are driven by them. for (int i = 0; i < VIRTKEY_COUNT; i++) { int vkId = i + VIRTKEY_FIRST; - std::vector inputMappings; uint32_t idForMapping = vkId; SwapMappingIfEnabled(&idForMapping); diff --git a/Core/KeyMap.cpp b/Core/KeyMap.cpp index 05f9a2564c..76dabe8d41 100644 --- a/Core/KeyMap.cpp +++ b/Core/KeyMap.cpp @@ -534,6 +534,7 @@ bool InputMappingsFromPspButton(int btn, std::vector *mapping return false; } bool mapped = false; + mappings->clear(); for (auto &iter2 : iter->second) { bool ignore = ignoreMouse && iter2.HasMouse(); if (mappings && !ignore) {