ebiten/inpututil
seebs 982a68e5a2
inpututil: use slices for maps where keys are small contiguous integers (#1169)
Durations for key presses and gamepad button presses were being stored
in map[int]int, where the key values were always small integers, and
furthermore, were always contiguous and contained the whole set. It's
much faster and cheaper to do those with slices.

We could probably do this with mouse buttons, but I was wary of that
code because I don't see any handling for more-than-three-button
mice. Similar logic could perhaps apply to touch events, but there
it might make more sense to use a dynamic allocation of some kind.

It might be more efficient to just swap the two slices back and
forth, computing the new values from the previous values and
then swapping the slice arrays themselves, but that seemed like
a more intrusive change.
2020-05-25 03:20:21 +09:00
..
inpututil.go inpututil: use slices for maps where keys are small contiguous integers (#1169) 2020-05-25 03:20:21 +09:00