function MyFunc(const Value: Integer): Integer;const MyArray: array[0..255] of Byte = ( ... ); // values of the array herebegin ... // Some codes here Result := Integer(MyArray[Value shr 58]);end; 会在MyFunc外面声明MyArray会增加重复
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;
会在MyFunc外面声明MyArray会增加重复调用MyFunc的性能吗?
Will declare
MyArray
outsideMyFunc
increases the performance of repeatedly calls to MyFunc?
不会.无论MyArray是函数的本地代码还是更广泛的常量,编译器都会生成相同的代码.类型化常量存储在可执行文件的数据段中,而不管其范围如何.