If you're so worried about performance, why are you using key strings? What if you have an enumeration? Like this:
enum Settings { WorldTime, ... };
Then your map will use int for keys, not strings. It should do comparisons between keys, because I believe that std :: map is implemented as a balanced tree. Comparing between ints is much faster than comparing strings.
Also, if you use an enumeration for keys, you can simply use an array, because an enumeration is essentially a map with some sort of character (i.e. WorldTime) up to an integer starting from zero. So do the following:
enum Settings { WorldTime, ... NumSettings };
And then declare mSettings as an array:
int mSettings[NumSettings];
Which has faster search time compared to std :: map. Then do the following:
DrawText(mSettings[WorldTime]);
Since you basically access the value in the array, not the map, it will be much faster and you wonβt have to worry about what you tried to do in the first or second place.
source share