From a564ac0701f7ee785458cd3bdae5f39d4017295d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 22 Oct 2016 07:05:19 +0200 Subject: [PATCH] input_keys_pressed - start splitting up big for loop into optimized smaller parts --- input/input_driver.c | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index 145cc6b09a..59fc2f5e65 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -617,6 +617,7 @@ void state_tracker_update_input(uint16_t *input1, uint16_t *input2) retro_input_t input_keys_pressed(void) { unsigned i; + bool states[RARCH_BIND_LIST_END]; retro_input_t ret; ret.type = 0; @@ -632,38 +633,50 @@ retro_input_t input_keys_pressed(void) else input_driver_block_libretro_input = false; - for (i = 0; i < RARCH_BIND_LIST_END; i++) + if (current_input->key_pressed) { - bool state = false; - if (((!input_driver_block_libretro_input && ((i < RARCH_FIRST_META_KEY))) - || !input_driver_block_hotkey) && current_input->key_pressed) - state = current_input->key_pressed(current_input_data, i); - - if (i >= RARCH_FIRST_META_KEY) - state |= current_input->meta_key_pressed(current_input_data, i); + for (i = 0; i < RARCH_BIND_LIST_END; i++) + { + if ((!input_driver_block_libretro_input && ((i < RARCH_FIRST_META_KEY))) + || !input_driver_block_hotkey) + states[i] = current_input->key_pressed(current_input_data, i); + } + } #ifdef HAVE_OVERLAY - state |= input_overlay_key_pressed(i); + for (i = 0; i < RARCH_BIND_LIST_END; i++) + states[i] |= input_overlay_key_pressed(i); #endif #ifdef HAVE_COMMAND - if (input_driver_command) + if (input_driver_command) + { + for (i = 0; i < RARCH_BIND_LIST_END; i++) { command_handle_t handle; handle.handle = input_driver_command; handle.id = i; - state |= command_get(&handle); + states[i] |= command_get(&handle); } + } #endif #ifdef HAVE_NETWORKGAMEPAD - if (input_driver_remote) - state |= input_remote_key_pressed(i, 0); + if (input_driver_remote) + { + for (i = 0; i < RARCH_BIND_LIST_END; i++) + states[i] |= input_remote_key_pressed(i, 0); + } #endif - if (state) + for (i = RARCH_FIRST_META_KEY; i < RARCH_BIND_LIST_END; i++) + states[i] |= current_input->meta_key_pressed(current_input_data, i); + + for (i = 0; i < RARCH_BIND_LIST_END; i++) + { + if (states[i]) ret.state |= (UINT64_C(1) << i); }