state: optimize xkb_state_led_update_all()

Before:
    ran@ran:~/src/libxkbcommon$ ./test/bench-key-proc
    ran 20000000 iterations in 6.623018074s

After:
    ran@ran:~/src/libxkbcommon$ ./test/bench-key-proc
    ran 20000000 iterations in 4.762291091s

Not that anyone needs to process millions of keys per second...

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2014-02-08 15:53:50 +02:00
parent 769b91c580
commit 04bacf87ba
1 changed files with 33 additions and 21 deletions

View File

@ -622,6 +622,7 @@ xkb_state_led_update_all(struct xkb_state *state)
xkb_mod_mask_t mod_mask = 0;
xkb_layout_mask_t group_mask = 0;
if (led->which_mods != 0 && led->mods.mask != 0) {
if (led->which_mods & XKB_STATE_MODS_EFFECTIVE)
mod_mask |= state->components.mods;
if (led->which_mods & XKB_STATE_MODS_DEPRESSED)
@ -630,9 +631,14 @@ xkb_state_led_update_all(struct xkb_state *state)
mod_mask |= state->components.latched_mods;
if (led->which_mods & XKB_STATE_MODS_LOCKED)
mod_mask |= state->components.locked_mods;
if (led->mods.mask & mod_mask)
state->components.leds |= (1u << idx);
if (led->mods.mask & mod_mask) {
state->components.leds |= (1u << idx);
continue;
}
}
if (led->which_groups != 0 && led->groups != 0) {
if (led->which_groups & XKB_STATE_LAYOUT_EFFECTIVE)
group_mask |= (1u << state->components.group);
if (led->which_groups & XKB_STATE_LAYOUT_DEPRESSED)
@ -641,11 +647,17 @@ xkb_state_led_update_all(struct xkb_state *state)
group_mask |= (1u << state->components.latched_group);
if (led->which_groups & XKB_STATE_LAYOUT_LOCKED)
group_mask |= (1u << state->components.locked_group);
if (led->groups & group_mask)
state->components.leds |= (1u << idx);
if (led->ctrls & state->keymap->enabled_ctrls)
if (led->groups & group_mask) {
state->components.leds |= (1u << idx);
continue;
}
}
if (led->ctrls & state->keymap->enabled_ctrls) {
state->components.leds |= (1u << idx);
continue;
}
}
}