memset and related things
bearophile
bearophileHUGS at lycos.com
Wed Sep 23 03:17:07 PDT 2009
Walter Bright:
> Java does do some escape analysis to try and allocate heap objects on
> the stack instead, but I don't know how effective this is, and even that
> won't help if you try to embed a value aggregate into a class:
>
> struct S { int x, y, z; }
>
> class C
> {
> S v; // in Java this would require a second heap allocation
> }
I have discussed with LDC devs an improvement of that idea (it was discussed in this newsgroup too):
class C1 { int x, y, z; }
class C2 {
scope C1 c;
}
This idea raises few problems, but I think they can be solved.
You can special-case the management of such objects scope-allocated inside other objects. Or you can just add an invisible field to that C2 class, the reference to c.
Bye,
bearophile
More information about the Digitalmars-d
mailing list