little speed up in c++ code