After checking the source code committed, I wonder do we really have to run extra code for a seldom used situation in the basic frequently used api?
take Sprite.getWidth (not only this method) for example, the most frequently used case is just get the width as fast as possible, if we need to get a non-transformed value, it can use other way easily. Why have to run extra code for such a simple and heavily used api?
In a game loop, these frequently used api should be implemented as fast as possible.
It's good to add new features, please take performance into consideration.
Comments
Likes: n1cke
We should take each step carefully to keep these results.
For most user, maybe will not notice these extra code run, but it really more or less take time.
getWidth() has always involved matrix transform as far as I recall, because actual geometry must be transformed according to setScale()/setRotation()/... in order to compute the Sprite's actual width. IMHO it should be cached somehow, but that kind of changes are error prone, and I didn't dare doing them.
Likes: n1cke, totebo
Is overload a good implementation for lua?
If it is,all these similar API like getLogicalWidth and getContentWidth, setTexture and setTextureRegion can implemented this way.But it was not.
For simple things like the width or position of sprite, when you know there are no transformations, you could cache them in a Lua table anyhow - it could be faster because you don't have to go through the expense of using the Lua C interface.
I don't have many problems with the speed of Gideros. But I come from a world of 1 or 2 Mhz processors with 4K of RAM and no more than 8 bits to play with - and having to make an arcade conversion run on the thing at 60hz !
Nowadays I code very lazily and everything runs at 60hz - why shouldn't it? - you have a min of 500Mhz, 512MB Ram, a GPU that can push out thousands of sprites, etc...
Saying all that, if you want to start sifting over the code looking for obvious optimisations then you should do. Be aware though that you may be wasting your time as some things are coded to make them more maintainable and the compiler will also spot obvious optimisations too and implement them at compile time (eg calling a function that just calls another function - the middle function will be stripped by the compiler).
Likes: n1cke
https://deluxepixel.com
However you're right that there may be a very small cpu overhead, but in most (or all) cases where overloading is used and where code needs to be added to check arguments, the extra code is nothing compared to the sum of real function to be performed plus lua to C bridging.
Likes: n1cke, SinisterSoft
Maybe I'm Over sensitive on that.