Say that I have the following situation:
void myFunc()
{
int x;
//Do something with x
}
"x" is placed on the stack which is no doubt fast.
Now, "myFunc" is called very frequently, lets say 10 times per second. Is it plausible to do something like this:
int x;
void myFunc()
{
//Do something with x
}
so that x gets allocated in the applications data segment. but it is allocated only once. Since "myFunc" is called so frequently, does the second approach deliver any performance benefits?
x
is stored in the applications data segment, not on the heap. – Gabor Angyal Feb 06 '15 at 08:58void otherFunc() { /* do something weird with x */ }
– gnat Feb 06 '15 at 09:01register int i;
to advise the compiler to keep this variable in registers. I wonder if today's C-compilers still do this. – ott-- Feb 08 '15 at 00:57