Optimizing software in C++