I did some profiling on my physics engine, and noticed that my 3d-vector''s constructor is hogging 15% of the performance. It gets called a lot, as all my vector operators use it to return the result.
This is the constructor:
CVector(float X, float Y, float Z) : x(X), y(Y), z(Z) {}
And the plus-operator, as an example:
CVector operator+(const CVector& V) {
return CVector(V.x+x, V.y+y, V.z+z);
}
Naturally vector addition, multiplication and all the others are called enormously often, but spending 15% on the constructor brings tears to my eyes. Am I doing something wrong here?