Revised RFC on range design for D2
Sergey Gromov
snake.scaly at gmail.com
Fri Oct 3 07:43:02 PDT 2008
Fri, 03 Oct 2008 20:59:54 +0800,
KennyTM~ wrote:
> Sergey Gromov wrote:
> > What's wrong with a.opIndexAssign(b, a.opIndex(b) + c)?
>
> Probably performance.
>
> Consider seeking to the end of a 100M-node single-linked list, and
> increase its content by 1.
>
> But I agree that if something like .opIndexAddAssign() is not defined,
> the compiler should fall back to use a.opIndexAssign(b, a.opIndex(b)+c).
>
> (The same idea can be extended to properties and .opSlice() )
No, if you want performance in this particular case you define
ref int opIndex()
because I think whenever compiler encounters a[x]++ it should first test
whether a[x] is an lvalue and if yes use it accordingly. And only if it
is not it should fall back to .opIndexAddButProbablyNotAssign() special
overloads.
More information about the Digitalmars-d-announce
mailing list