diff --git a/src/twn_input.c b/src/twn_input.c index a589720..63d1510 100644 --- a/src/twn_input.c +++ b/src/twn_input.c @@ -156,6 +156,7 @@ static void input_unbind_code_from_action(struct input_state *input, break; } + /* stop early, this won't change */ if (is_bound) break; } @@ -166,12 +167,10 @@ static void input_unbind_code_from_action(struct input_state *input, } /* remove the element to unbind and shift the rest so there isn't a gap */ - if (action->num_bindings == SDL_arraysize(action->bindings)) { - size_t elements_after_index = action->num_bindings - index; - size_t shifted_size = elements_after_index * (sizeof action->bindings[0]); - memmove(action->bindings + index, action->bindings + index + 1, shifted_size); - --action->num_bindings; - } + size_t elements_after_index = action->num_bindings - index; + size_t shifted_size = elements_after_index * sizeof action->bindings[0]; + memmove(action->bindings + index, action->bindings + index + 1, shifted_size); + --action->num_bindings; }