From 2601c01a0522fec5e778d9fe95f83ebefe45a5f4 Mon Sep 17 00:00:00 2001 From: Shute Date: Mon, 29 Jan 2024 11:16:28 +0800 Subject: [PATCH] Replace unnecessary `Vec` with a simple flag for pressed state check (#455) --- src/input_map.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/input_map.rs b/src/input_map.rs index 219b06d8..4ee004f5 100644 --- a/src/input_map.rs +++ b/src/input_map.rs @@ -323,20 +323,20 @@ impl InputMap { // Generate the raw action presses for (action, input_vec) in self.iter() { - let mut inputs = Vec::new(); + let mut pressed = false; let mut action_datum = ActionData::default(); for input in input_vec { action_datum.axis_pair = input_streams.input_axis_pair(input); if input_streams.input_pressed(input) { - inputs.push(input.clone()); + pressed = true; action_datum.value += input_streams.input_value(input, true); } } - if !inputs.is_empty() { + if pressed { action_datum.state = ButtonState::JustPressed; }