Just wondering is this kind of code recommended to increase performance?
void functionCalledLotsofTimes() {
static int *localarray = NULL;
//size is a large constant > 10 000
if (localarray == NULL) localarray = new int[size];
//Algorithm goes here
}
I'm also curious how static variables are implemented by modern c++ compilers like g++. Are they handled like global variables?