function MyFunc(const Value: Integer): Integer;
const
MyArray: array[0..255] of Byte = ( ... ); // values of the array here
begin
... // Some codes here
Result := Integer(MyArray[Value shr 58]);
end;
Run Code Online (Sandbox Code Playgroud)
会声明MyArray外面MyFunc增加反复调用的性能MyFunc吗?
会声明
MyArray外部MyFunc增加反复调用MyFunc的性能吗?
不会.编译器将生成相同的代码,无论MyArray函数是本地的,还是更广泛的常量.类型化常量存储在可执行文件的数据段中,而不管其范围如何.
| 归档时间: |
|
| 查看次数: |
108 次 |
| 最近记录: |