Optimizing C ++