my question is more for general programming knowledge. I work in a sketch with arduino for some time and by it grown, the arduino become slower. So I start to wonder is there some way or habbit to upgrade performance in the same program.
For example, is it better to use function inside function or to cash it as often as you can.
like:
doSomething(thinsReturnAnInt(someVar));
or do
int cashedReturn = thinsReturnAnInt(someVar);
doSomething(cashedReturn);
or this is not changing anything...
Another thing. Is it help to use variable smaller like int_t instead of int if the size fit, or it will do no difference if you don't miss physical or ram memory?
Finnaly is there some other resource where I could fine some trick to do better programing ( for beginner BTW... ).
The first way uses more stack space. The second way uses more SRAM. The total memory used remains exactly the same, though.
Another thing. Is it help to use variable smaller like int_t instead of int if the size fit, or it will do no difference if you don't miss physical or ram memory?
int_t isn't a valid type. int8_t is. So is int16_t. The _t types have fixed sizes, regardless of the platform the code is running on. Since you are writing code for the Arduino. use int. Or, use byte if the values will fit.