Cut a rectangle: Difference between revisions

Updated D entry
(Fixed comment to D entry)
(Updated D entry)
Line 402:
core.stdc.string, std.typetuple;
 
template Range(int stop) { // for manual loop unroll
static if (stop <= 0)
alias TypeTuple!() Range;
Line 409:
}
 
__gshared enum int[2][4] dir = [[0, -1], [-1, 0], [0, 1], [1, 0]];
 
__gshared ubyte*[] grid;
__gshared int w, h, len;
__gshared ulong cnt;
Line 447:
 
len = (h + 1) * (w + 1);
{
grid = cast(ubyte*)alloca(len);
if ( // grid == null)new ubyte[len]; // slower
exitubyte* ptr = cast(1ubyte*)alloca(len);
memset if (grid,ptr 0,== lennull);
exit(1);
grid = ptr[0 .. len];
}
grid[] = 0;
len--;
 
//next = [-1, -w - 1, 1, w + 1]; // slow
next[0] = -1;
next[1] = -w - 1;