Re: [GD-General] C style math libraries versus "proper" C++ maths
Brought to you by:
vexxed72
From: Andras B. <and...@gm...> - 2006-03-25 22:43:49
|
Isn't it fun when theory meets practice? :) With a proper compiler, if you used references, and the function was inlined, then the function should just work straight on the values, no dereferencing, no copying to the stack, etc.. However, last time I checked, this was still not the case, so I still pass all my vectors and matrices by value, rather than reference. Note that if the function is inlined, then it shouldn't do the copy to stack in any case.. So my advice would be to simply pass by value. Andras Saturday, March 25, 2006, 3:26:53 PM, you wrote: > I remember some passed days in gameprogramming. > > 3D matrix operations and its implementation on PIII900MHz. > a class containing an array of float, somethingvery simple. > And for basic operation, you can pass on reference(using > keyword) or pointer (* keyword) or pass directly the array (so > allfloats are placed into stack. > Case 1 Case 2 : only 4 bytes on the stack butall computing is using a deference (-> operator) > Case 3 : for 4x4 array (x,y,z,w), 16 floats so 16 x4 = 64 bytes per matrix. > > At this time the fastest method was the3. > > So better code isn't always the faster one;) > |