Struct Constructor Lazy
Adam D. Ruppe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jul 12 06:49:09 PDT 2017
On Wednesday, 12 July 2017 at 11:00:54 UTC, Jiyan wrote:
> when A(0) is called I would want here optimal performance, so
> there doesnt even need to be a value pushed on the stack (i=0),
> what would be like having a constructor with zero arguments (i
> is never used!).
This is so, so irrelevant. Even if it isn't optimized out (which
it probably is), pushing a zero to the stack is so extremely
cheap that you'd probably not notice it, especially compared to
reading something from a file.
> Im pretty new to D, can somebody tell me how i would do this?
> Is this(lazy int i){ ... a solution?
That's actually more expensive than just sending the zero!
More information about the Digitalmars-d-learn
mailing list