Why is the vector class so weird?

why this -
Code:
inline b2Vec2 operator + (const b2Vec2& a, const b2Vec2& b)
{
   b2Vec2 v; v.Set(a.x + b.x, a.y + b.y);
   return v;
}

instead of this -
Code:
inline b2Vec2 operator + (const b2Vec2& a, const b2Vec2& b)
{
   return b2Vec2(a.x + b.x, a.y + b.y);
}

?
That's slowing down the debug version, I can see the arguments with a breakpoint and the returned value when the debugger steps out of the function (in Visual C++). Any other reason why using that code? Maybe for other IDEs? Wouldn't it be better then if the developer could choose?
it makes no difference in an optimised build.

g++ optimises it to the same thing.
snake5 wrote:
I can see the arguments with a breakpoint and the returned value when the debugger steps out of the function (in Visual C++). Any other reason why using that code?
Maybe to alter the result easier?
thesleepless:
I know.. but I'd like to have a fast debug build, to debug the game, fix the bugs, solve problems as fast as possible -- to make a better game faster and finish it without getting bored when compiling my code! 🙂

makc:
how - earlier?
both functions (the slow one that's in this version of box2d and the fast one) do the same.

I want to hear from Erin about this. 😕
Before you get antagonistic, don't forget the strawman clause in the documentation:
http://www.box2d.org/manual.html#d0e451
😉
Quote:
Seriously, if you have feedback about anything related to Box2D, please leave a comment in the forum.

Yes, that's what I'm doing now. 😉
Originally the vector class did not have constructors because I was considering placing vectors in unions. C++ does not allow you to place classes in a union if they have a non-default constructor.
But why do the functions have more code than needed? Am I the only one who has a reason for getting my debug build faster? 😀
I already gave the reason. Was I unclear?

Your revised version of the vector addition operator uses a constructor that didn't exist when the vector class was first written. So your version of the addition operator would have failed to compiled.

When finally added the constructor to the vector class, I did not find every spot in the code where using the constructor could reduce the number of lines of code.

Would you mind providing a profile of your performance problems in the debug build? Is this function the bottleneck?
There's the problem - it is the bottleneck, at least - one of them..
My code uses the constructor that's available:
Code:
b2Vec2( float _x, float _y ) : x(_x), y(_y) {}

That's why I don't understand why my code would fail to compile..

I'll give a screenshot of CodeAnalyst, if you need it..
EDIT: here it is - http://usera.imagecave.com/snake5/ca_scr.png

Original thread: https://box2d.org/forum/viewtopic.php?t=1917