Which of the following is faster?:
A :ORCode:float f1; float f2; //... f1 and f2 are modified f1 *= x / y; f2 *= x / y;
B:So is it quicker to make an extra float and only do the multiplication once? This is something I need to do probably 500 times per second.Code:float f1; float f2; //... f1 and f2 are modified float temp = x / y; f1 *= temp; f2 *= temp;
I am also wondering whether there are any unmentioned costs to creating an object. I have a Vector3d class which has 3 float members and a heap of methods. If I create one of those is that going to take as long as creating a struct with 3 floats? Also, does it take up the same amount of memory as a struct with 3 floats?