Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
move sorted invariant into PoolTable
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinNowak committed Jan 18, 2015
1 parent 49a0ce3 commit eab6372
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/gc/gc.d
Original file line number Diff line number Diff line change
Expand Up @@ -1437,23 +1437,12 @@ struct Gcx
if (inited)
{
//printf("Gcx.invariant(): this = %p\n", &this);
pooltable.Invariant();

for (size_t i = 0; i < npools; i++)
{ auto pool = pooltable[i];

pool.Invariant();
if (i == 0)
{
assert(minAddr == pool.baseAddr);
}
if (i + 1 < npools)
{
assert(pool.opCmp(pooltable[i + 1]) < 0);
}
else if (i + 1 == npools)
{
assert(maxAddr == pool.topAddr);
}
if (pooltable.length)
{
assert(minAddr == pooltable[0].baseAddr);
assert(maxAddr == pooltable[$ - 1].topAddr);
}

foreach (range; ranges)
Expand Down Expand Up @@ -3129,14 +3118,14 @@ nothrow:
npools = nlen;
}

ref Pool* opIndex(size_t idx) pure
ref inout(Pool*) opIndex(size_t idx) inout pure
in { assert(idx < length); }
body
{
return pools[idx];
}

Pool*[] opSlice(size_t a, size_t b) pure
inout(Pool*)[] opSlice(size_t a, size_t b) inout pure
in { assert(a <= length && b <= length); }
body
{
Expand All @@ -3145,6 +3134,15 @@ nothrow:

alias opDollar = length;

debug (INVARIANT)
void Invariant() const
{
if (!npools) return;

foreach (i, pool; pools[0 .. npools - 1])
assert(pool.opCmp(pools[i + 1]) < 0);
}

private:
Pool** pools;
size_t npools;
Expand Down

0 comments on commit eab6372

Please sign in to comment.