On 30 May 2013 11:13, Johannes Pfau <nos...@example.com> wrote: > Am Thu, 30 May 2013 10:42:17 +0100 > schrieb Iain Buclaw <ibuc...@ubuntu.com>: > >> >> This is more of a lazy init that won't affect start-up speed. Note: >> this idea is based off what C++ (g++) does for say - static A a = new >> A(); >> > > I see. > >> >> I don't think it would have much slow down. Albeit the first >> initialisation would jump through the druntime library twice, but >> there after it's a single/two instruction test. Pretty negligible - >> but I'm not a speeeeeeeeed demon or freak who wants everything >> compiled with -fOMG-fast. =) > > I'm more worried about adding many roots to the GC. The code which > checks the guard variable is probably neglectable. >
Speed won't at all be a problem in that aspect. All roots are kept in an array, so during collection, rather than the following: --- mark (&_tlsstart, &_tlsend - &_tlsstart); --- It will be doing: --- mark (this.roots, this.roots + this.nroots); --- Regards -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';