If I have a glm::vec3
for example and I want to assign a new value to it, which of the following methods is faster?
vec = glm::vec3(1, 2, 3);
or
vec.x = 1;
vec.y = 2;
vec.z = 3;
If I understand correctly, the first method does the following:
- Calls the
glm::vec3
constructor to create a new temporary vector on the stack - Calls the copy assigment operator of
glm::vec3
to copy the new vector
Whereas the second method is just assignments and avoids creating a dummy temporary vector, so why I would ever want to do a ton of *** instead of just assigning my values?