阅读背景:

是否值得将局部变量设置为静态以防止不断重新创建?

来源:互联网 

Suppose I have a function in C/C++ which is called quite frequently (let's say it's connect to a timer which is timeout at least 10 times per second) and that function needs to use a given variable/container (an integer or maybe a string or an array). Now, naturally enough, the process of creating this variable in memory costs some processor clocks; running the same function again and again therefore means I'll loose quite some "processor clock ticks" for doing exactly the same thing many times. This could be prevented by either making that variable global, member of the function's class or Suppose I have a function in C/C++ which is cal




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: