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?