Passing array as const slows down code?
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Sat Apr 28 04:17:36 PDT 2012
On 27/04/12 20:26, Steven Schveighoffer wrote:
> No, it can't. There can easily be another non-const reference to the same data.
> Pure functions can make more assumptions, based on the types, but it would be a
> very complex determination in the type system to see if two parameters alias the
> same data.
>
> Real optimization benefits come into play when immutable is there.
Question on the const/immutable distinction. Given that my function has inputs
of (size_t, size_t, Rating[]), how come the size_t's can be made immutable, but
the Rating[] can only be made const/const ref?
Is it because the size_t's can't conceivably be changed from outside while the
function is running, whereas the values in the array in principle can be?
More information about the Digitalmars-d-learn
mailing list