Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Fill method for Image ?  (Read 9872 times)

0 Members and 1 Guest are viewing this topic.

DarkRoku12

  • Full Member
  • ***
  • Posts: 203
  • Lua coder.
    • View Profile
    • Email
Re: Fill method for Image ?
« Reply #15 on: September 01, 2016, 06:09:47 am »
SFML is inefficient because lot of parts of it are bloated with getters/setters and other high-overhead boilerplate...
Directly accessing arrays/members is so much cleaner and faster !

Actually on release mode and optimizations enabled methods are almost ever inlined.

Remember that in ASM there is neither classes nor privacy at all.

       sf::Sprite spr ;
       float rot = spr.getRotation()  
 

with properly optimizations enabled is the same that:

       sf::Sprite spr ;
       float rot = spr.rotation  ;
 

However

      //example A1
       sf::Sprite spr ;
       float x = spr.getPosition().x ;
       float y = spr.getPosition().y ;
 

could be slower than:

   //example A2
       sf::Sprite spr ;
       sf::Vector2f pos = spr.getPosition() ;
       float x = pos.x
       float y = pos.y
 

BUT a good compiler with full optimizations should be able to do CSE (Common subexpresion elimination).

And the example A1 can be translated in A2.

If in the example A2 ( and in A1 too ) the variable "pos" its no used any more the compiler could do a "Allocation optimization"
Eliminating the allocation of pos and inling .x .y

ej:

   //example A2
       sf::Sprite spr ;
       float x = spr.x // -> .x from spr's internal vector.
       float y = spr.y  // -> y from spr's internal vector.
 


Compilers nowadays are very capable. You only need to know how use it and how code.

So, please, before make an assertion research a bit more.
 :D
« Last Edit: September 01, 2016, 06:12:32 am by DarkRoku »
I would like a spanish/latin community...
Problems building for Android? Look here

 

anything