In c++ i sometimes also got heavy performance improvments when i avoid random memory access. So looping over an array is often times much faster than accessing by key, since the calls can be vectorized better and the cpu cache can work more efficent.
gcc/gpp is also able to log the missed optimization opportunities with -fopt-info-missed and friends.