Original code contains doubleQHash search for a key (code below decomposed from original - for readability):
if (keyMap.contains( event->key() )) // QHash::contains() do the search of value-by-key
{
const int key = keyMap[ event->key() ]; // QHash::operator[] do the search of value-by-key again
const bool key_pressed = (event->type() == QEvent::KeyPress);
io.KeysDown[key] = key_pressed;
}
This is minor (possibly, due to small keyMap size, performance-irrelevant) issue, fixed in kinda 'less-readable way' (due to iterators usage), only for a next reason: to not worry about such place :smile:
Original code contains double
QHash
search for a key (code below decomposed from original - for readability):This is minor (possibly, due to small
keyMap
size, performance-irrelevant) issue, fixed in kinda 'less-readable way' (due to iterators usage), only for a next reason: to not worry about such place :smile: