summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2014-08-18 20:08:25 +0300
committerRan Benita <ran234@gmail.com>2014-08-18 20:08:53 +0300
commit80ae8e61ffe0677369e9f5f865ffe3ae76541816 (patch)
tree025bededac29e44470e2250b78a7eea4dc1a5560
parenta95c4e83e41eebce45d43d23b5c179d0f2a263ea (diff)
downloadlibxkbcommon-80ae8e61ffe0677369e9f5f865ffe3ae76541816.tar.gz
libxkbcommon-80ae8e61ffe0677369e9f5f865ffe3ae76541816.tar.bz2
libxkbcommon-80ae8e61ffe0677369e9f5f865ffe3ae76541816.zip
state: no need for loop in xkb_state_update_mask()
Signed-off-by: Ran Benita <ran234@gmail.com>
-rw-r--r--src/state.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/state.c b/src/state.c
index 94545bc..03463c8 100644
--- a/src/state.c
+++ b/src/state.c
@@ -786,25 +786,16 @@ xkb_state_update_mask(struct xkb_state *state,
xkb_layout_index_t locked_group)
{
struct state_components prev_components;
- xkb_mod_index_t num_mods;
- xkb_mod_index_t idx;
+ xkb_mod_mask_t mask;
prev_components = state->components;
- state->components.base_mods = 0;
- state->components.latched_mods = 0;
- state->components.locked_mods = 0;
- num_mods = xkb_keymap_num_mods(state->keymap);
-
- for (idx = 0; idx < num_mods; idx++) {
- xkb_mod_mask_t mod = (1u << idx);
- if (base_mods & mod)
- state->components.base_mods |= mod;
- if (latched_mods & mod)
- state->components.latched_mods |= mod;
- if (locked_mods & mod)
- state->components.locked_mods |= mod;
- }
+ /* Only include modifiers which exist in the keymap. */
+ mask = (xkb_mod_mask_t) ((1ull << xkb_keymap_num_mods(state->keymap)) - 1u);
+
+ state->components.base_mods = base_mods & mask;
+ state->components.latched_mods = latched_mods & mask;
+ state->components.locked_mods = locked_mods & mask;
state->components.base_group = base_group;
state->components.latched_group = latched_group;