ara*_*dia 4 c++ gcc memory-management
只是想知道这种代码建议提高性能吗?
void functionCalledLotsofTimes() {
static int *localarray = NULL;
//size is a large constant > 10 000
if (localarray == NULL) localarray = new int[size];
//Algorithm goes here
}
Run Code Online (Sandbox Code Playgroud)
我也很好奇现代c ++编译器如g ++如何实现静态变量.它们是否像全局变量一样处理?