X-Git-Url: https://git.llucax.com/software/dgc/cdgc.git/blobdiff_plain/624a6db4949f3e3a7ebba7506166e0f9d4be3e5e..67f00b96c70725ee445641a158a97fe4f6e735d3:/rt/gc/cdgc/bits.d diff --git a/rt/gc/cdgc/bits.d b/rt/gc/cdgc/bits.d index a2e5e0d..4d25362 100644 --- a/rt/gc/cdgc/bits.d +++ b/rt/gc/cdgc/bits.d @@ -26,7 +26,8 @@ module rt.gc.cdgc.bits; -import libc = rt.gc.cdgc.libc; +import cstdlib = tango.stdc.stdlib; +import cstring = tango.stdc.string; private extern (C) void onOutOfMemoryError(); @@ -61,9 +62,13 @@ struct GCBits void Dtor() { + // Even when free() can be called with a null pointer, the extra call + // might be significant. On hard GC benchmarks making the test for null + // here (i.e. not making the call) can reduce the GC time by almost + // ~5%. if (data) { - libc.free(data); + cstdlib.free(data); data = null; } } @@ -80,7 +85,7 @@ struct GCBits { this.nbits = nbits; nwords = (nbits + (BITS_PER_WORD - 1)) >> BITS_SHIFT; - data = cast(uint*)libc.calloc(nwords + 2, uint.sizeof); + data = cast(uint*)cstdlib.calloc(nwords + 2, uint.sizeof); if (!data) onOutOfMemoryError(); } @@ -156,7 +161,7 @@ struct GCBits for (;d1!=dEnd;++d1) *d1=0u; } else { - libc.memset(data + 1, 0, nwords * uint.sizeof); + cstring.memset(data + 1, 0, nwords * uint.sizeof); } } @@ -172,7 +177,7 @@ struct GCBits for (;d1!=dEnd;++d1,++d2) *d1=*d2; } else { - libc.memcpy(data + 1, f.data + 1, nwords * uint.sizeof); + cstring.memcpy(data + 1, f.data + 1, nwords * uint.sizeof); } } @@ -216,3 +221,6 @@ unittest b.Dtor(); } + + +// vim: set et sw=4 sts=4 :