Then you would need to write a benchmark for this code an measure the hot points, then you can decide where to intervene. Performance optimization can’t be done blindly just reading the code (apart from some well-known optimization patterns). It also depends on your scenario and usages. Keep in mind that often you can’t push optimization too far towards speed AND memory: in many scenarios those vectors are orthogonal.