Open 3096 opened 5 years ago
Unordered map can be used for constant time access, and even ordered map is logarithmic time.
Same applies to arrays like:
https://github.com/XorTroll/Plutonium/blob/0fefac2455683f2e98bb7091c5891ebb222a8683/Plutonium/Source/pu/ui/elm/elm_Menu.cpp#L411-L415
This code is essentially checking if this->isel
and this->previsel
(whatever those are) are in range of 0 to itms.size(), no need to iterate. (It also should always be in range?)
Iterating maps is unnecessary and a loss of performance, especially if a map size gets large.
For this example: https://github.com/XorTroll/Plutonium/blob/0fefac2455683f2e98bb7091c5891ebb222a8683/Plutonium/Source/pu/ui/render/render_SDL2.cpp#L35-L38 Consider something like: