diff options
author | Lioncash <mathew1800@gmail.com> | 2021-12-13 16:18:02 +0100 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2021-12-13 16:18:04 +0100 |
commit | a9d39b68952bf3ce9607a5947f056eb990e2b430 (patch) | |
tree | 03c083b4c17c1d8365177f73065c410207305222 /src/input_common/input_engine.cpp | |
parent | input_engine: Avoid redundant map lookups (diff) | |
download | yuzu-a9d39b68952bf3ce9607a5947f056eb990e2b430.tar yuzu-a9d39b68952bf3ce9607a5947f056eb990e2b430.tar.gz yuzu-a9d39b68952bf3ce9607a5947f056eb990e2b430.tar.bz2 yuzu-a9d39b68952bf3ce9607a5947f056eb990e2b430.tar.lz yuzu-a9d39b68952bf3ce9607a5947f056eb990e2b430.tar.xz yuzu-a9d39b68952bf3ce9607a5947f056eb990e2b430.tar.zst yuzu-a9d39b68952bf3ce9607a5947f056eb990e2b430.zip |
Diffstat (limited to 'src/input_common/input_engine.cpp')
-rw-r--r-- | src/input_common/input_engine.cpp | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/src/input_common/input_engine.cpp b/src/input_common/input_engine.cpp index a4a07d4ac..9c17ca4f7 100644 --- a/src/input_common/input_engine.cpp +++ b/src/input_common/input_engine.cpp @@ -10,41 +10,31 @@ namespace InputCommon { void InputEngine::PreSetController(const PadIdentifier& identifier) { std::lock_guard lock{mutex}; - if (!controller_list.contains(identifier)) { - controller_list.insert_or_assign(identifier, ControllerData{}); - } + controller_list.try_emplace(identifier); } void InputEngine::PreSetButton(const PadIdentifier& identifier, int button) { std::lock_guard lock{mutex}; ControllerData& controller = controller_list.at(identifier); - if (!controller.buttons.contains(button)) { - controller.buttons.insert_or_assign(button, false); - } + controller.buttons.try_emplace(button, false); } void InputEngine::PreSetHatButton(const PadIdentifier& identifier, int button) { std::lock_guard lock{mutex}; ControllerData& controller = controller_list.at(identifier); - if (!controller.hat_buttons.contains(button)) { - controller.hat_buttons.insert_or_assign(button, u8{0}); - } + controller.hat_buttons.try_emplace(button, u8{0}); } void InputEngine::PreSetAxis(const PadIdentifier& identifier, int axis) { std::lock_guard lock{mutex}; ControllerData& controller = controller_list.at(identifier); - if (!controller.axes.contains(axis)) { - controller.axes.insert_or_assign(axis, 0.0f); - } + controller.axes.try_emplace(axis, 0.0f); } void InputEngine::PreSetMotion(const PadIdentifier& identifier, int motion) { std::lock_guard lock{mutex}; ControllerData& controller = controller_list.at(identifier); - if (!controller.motions.contains(motion)) { - controller.motions.insert_or_assign(motion, BasicMotion{}); - } + controller.motions.try_emplace(motion); } void InputEngine::SetButton(const PadIdentifier& identifier, int button, bool value) { |