Let's say I have a very long method which basically creates a responsive and resizable layout for a user interface by using a few fixed values and a few variable ones taken from an element's coordinates and width/height sizes. To obtain the desired layout, my code needs to perform basic but repetitive math operations (additions, subtractions, multiplications and divisions) to get every element's coordinates and size.
My code is written in Objective-C.
Let's also say that I want my code to be extremely fast, because it will run on low-performance devices, such as mobile devices.
Since I want to get high performance, does making a very precise declaration for the variable have a performance impact? For example, the compiler will know if the value is a const
or unsigned
, and optimize the code right along.
For example, which of these cases is faster than the others?
const unsigned int kInteger = 20;
const int kInteger = 20;
int integer = 20;
unsigned int integer = 20;
In other words, does helping the compiler, really have a performance impact? Or is this just a waste of time since it's all just micro-optimization?