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;
Will declare MyArray
outside MyFunc
increases the performance of repeatedly calls to MyFunc
?
Will declare
MyArray
outsideMyFunc
increases the performance of repeatedly calls to MyFunc?
No. The compiler will produce identical code no matter if MyArray
is local to the function, or a constant at a wider scope. Typed constants are stored in the data segment of the executable, irrespective of their scope.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With