So I have a question that sprung out of curiosity as I was programming; is it better to reuse an existing variable or create a new variable for the following situation:
1 2 3 4 5 6 7 8 9
/* Is this faster: */
glm::mat4 newViewModelMatrix = (*existingViewMatrix) * (*existingModelMatrix);
/* Or is this faster? */
glm::mat4 existingViewModelMatrix; /* declared in class header - initial value assigned in class constructor */
existingViewModelMatrix = (*existingViewMatrix) * (*existingModelMatrix);
the first is equivalent to the copy constructor. glm:mat4 newViewModelMatrix ( (*existingViewMatrix) * (*existingModelMatrix) );
So it depends which one is cheaper the assignment or the copy constructor. This varies from class to class and therefore cannot be answered in general.