On Sun, 03 May 2015 04:40:42 +0000, weaselcat wrote: > On Saturday, 2 May 2015 at 16:24:17 UTC, Ola Fosheim Grøstad wrote: >> Not impossible, but if you can do it you probably often can replace it >> with a stack allocation. > > AFAIK LDC already has a pass that does this, I'm not sure how well it > works.
i don't thing that such pass in general worth the efforts. D programmers tend to use structures for local and short-lived objects. if i did `new`, chances are that i really want it on heap, and it will not be optimisable (i either returning pointer, or passing it to some function that stores it somewhere). so it can catch very rare cases for the cost of expensive interprocedural analysis. this makes some sense for C++, though.
signature.asc
Description: PGP signature