<div dir="ltr"><div><div><div><div>Hello,<br><br>Here's the code:<br><br>procedure dump(const a: array of string);<br>var<br>  i : integer;<br>begin<br>  for i:=0 to length(a)-1 do<br>    writeln(a[i]);<br>end;<br><br>
const<br>  fast : array [0..2] of string = ('aa','bb','cc');<br><br>begin<br>  dump(['a','b','c']);<br>  dump(fast);<br>end.<br><br></div>The first call to dump(), where the array is passed as "inline" declaration, consists of building of an open array with string constants:<br>
<br>    movl    $_$PROGRAM$_Ld4,%eax<br>    movl    %eax,-12(%ebp)<br>    movl    $_$PROGRAM$_Ld5,%eax<br>    movl    %eax,-8(%ebp)<br>    movl    $_$PROGRAM$_Ld6,%eax<br>    movl    %eax,-4(%ebp)<br>    leal    -12(%ebp),%eax<br>
    movl    $2,%edx<br>    call    P$PROGRAM_DUMP$array_of_ANSISTRING<br><br></div>the second call, is however just passing a reference to the constant of the open array ("fast")<br><br>    movl    $TC_P$PROGRAM_FAST,%eax<br>
    movl    $2,%edx<br>    call    P$PROGRAM_DUMP$array_of_ANSISTRING<br><br></div><div>Question: would it be reasonable for the compiler to turn an inline declaration of ['a','b','c'], into a constant implicitly?<br>
</div><div>That would save some instructions to make a call <br>  dump(['a','b','c']);<br>is there an optimization switch for that already?<br></div><div></div><div></div><div><br></div>thanks,<br>
</div>Dmitry<br></div>