TempAlloc review starts now
simendsjo
simen.endsjo at pandavre.com
Mon Jun 6 01:56:32 PDT 2011
I have very limited experience with D and haven't taken the time to understood the code, but here are
some easy nitpicks :)
----
imports: Should stuff in core really depend on phobos? Isn't much of the reason for core to allow
different "standard" libraries like tango?
177: should 16 be alignBytes?
199/299: unnecessary initializers
246: Move inUse.destroy() up to clearing of inUse?
291: Move assumption comment to assertion. Something like this:
bool isPowerOf(int pow, int num) {
if(num <= 0 || pow <= 0)
return false;
else if(pow == 1)
return true;
else if(pow == num)
return true;
else {
double n = cast(double)num / cast(double)pow;
if(n%1 != 0)
return false;
else if(n == pow)
return true;
else
return isPowerOf(pow, cast(int)n);
}
}
unittest {
static assert(isPowerOf(1, 0) == false); // num==0
static assert(isPowerOf(1, 5) == true); // pow==1
static assert(isPowerOf(3, 3) == true); // pow==num
static assert(isPowerOf(2, 2) == true);
static assert(isPowerOf(2, 3) == false);
static assert(isPowerOf(2, 4) == true);
static assert(isPowerOf(2, 1024) == true);
static assert(isPowerOf(2, 1023) == false);
}
and in getAligned:
static assert(isPowerOf(2, alignBytes), "getAligned requires alignBytes to be a power of 2")
383/408/418/428: getState called without () (deprecated behavior, right..?)
686: missing () (same as above)
More information about the Digitalmars-d
mailing list