is there a performance difference between doing something like:
void function() {
char bufgfer[256];
// ...
}
and
void function() {
static char bufgfer[256];
// ...
}
I know it changed the way the function will work, but how about the performance? is the second one faster?
hanks
The first one is probably faster if the buffer ends up in a cache near the CPU.
If you thought that the first one was slower because the buffer would somehow be allocated at run time, then, no, this is not the reason. All this is handled by the compiler at compile time. Moreover, making the buffer static will probably keep it out of the cache. (But who knows, or cares?)
It seems to me that you’re considering premature optimizations.