函数外部声明会增加重复调用函数的性能吗?

Aeo*_*yan 5 delphi function

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吗?

Dav*_*nan 7

会声明MyArray外部MyFunc增加反复调用MyFunc的性能吗?

不会.编译器将生成相同的代码,无论MyArray函数是本地的,还是更广泛的常量.类型化常量存储在可执行文件的数据段中,而不管其范围如何.