module rt.gc.cdgc.bits;
-import rt.gc.cdgc.libc;
+import cstdlib = tango.stdc.stdlib;
+import cstring = tango.stdc.string;
private extern (C) void onOutOfMemoryError();
version (DigitalMars)
{
version = bitops;
+ import std.intrinsic;
}
else version (GNU)
{
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)
{
- free(data);
+ cstdlib.free(data);
data = null;
}
}
{
this.nbits = nbits;
nwords = (nbits + (BITS_PER_WORD - 1)) >> BITS_SHIFT;
- data = cast(uint*)calloc(nwords + 2, uint.sizeof);
+ data = cast(uint*)cstdlib.calloc(nwords + 2, uint.sizeof);
if (!data)
onOutOfMemoryError();
}
}
}
else
- { uint result;
-
+ {
//result = (cast(bit *)(data + 1))[i];
//(cast(bit *)(data + 1))[i] = 0;
uint* p = &data[1 + (i >> BITS_SHIFT)];
uint mask = (1 << (i & BITS_MASK));
- result = *p & mask;
+ uint result = *p & mask;
*p &= ~mask;
return result;
}
for (;d1!=dEnd;++d1)
*d1=0u;
} else {
- memset(data + 1, 0, nwords * uint.sizeof);
+ cstring.memset(data + 1, 0, nwords * uint.sizeof);
}
}
for (;d1!=dEnd;++d1,++d2)
*d1=*d2;
} else {
- memcpy(data + 1, f.data + 1, nwords * uint.sizeof);
+ cstring.memcpy(data + 1, f.data + 1, nwords * uint.sizeof);
}
}
b.Dtor();
}
+
+
+// vim: set et sw=4 sts=4 :