new should lower to a template function call
Walter Bright
newshound2 at digitalmars.com
Thu Jul 23 05:12:30 UTC 2020
On 7/22/2020 6:05 PM, Adam D. Ruppe wrote:
> 2) the compiler should be free to cheat a little for optimization; if it can see
> the var never escapes, it might even still pop it on the stack (perhaps the
> function receives a pointer to the memory and if null, it is responsible for
> allocing it). This may not be implemented but the spec should at least be
> written to allow it later. This kind of optimization can be a real winner with
> scope too.
The compiler already does this if the variable being new`d is `scope`.
More information about the Digitalmars-d
mailing list