@@ -1335,7 +1335,7 @@ class ConservativeGC : GC
1335
1335
//
1336
1336
private void getStatsNoSync (out core.memory.GC.Stats stats) nothrow
1337
1337
{
1338
- foreach (pool; gcx.pooltable[0 .. gcx.npools ])
1338
+ foreach (pool; gcx.pooltable[])
1339
1339
{
1340
1340
foreach (bin; pool.pagetable[0 .. pool.npages])
1341
1341
{
@@ -1353,7 +1353,7 @@ class ConservativeGC : GC
1353
1353
for (List * list = gcx.bucket[n]; list; list = list.next)
1354
1354
freeListSize += sz;
1355
1355
1356
- foreach (pool; gcx.pooltable[0 .. gcx.npools ])
1356
+ foreach (pool; gcx.pooltable[])
1357
1357
{
1358
1358
if (pool.isLargeObject)
1359
1359
continue ;
@@ -1491,7 +1491,6 @@ struct Gcx
1491
1491
debug (INVARIANT ) bool inCollection;
1492
1492
uint disabled; // turn off collections if >0
1493
1493
1494
- private @property size_t npools() pure const nothrow { return pooltable.length; }
1495
1494
PoolTable! Pool pooltable;
1496
1495
1497
1496
List* [B_NUMSMALL ] bucket; // free list for each small size
@@ -1591,9 +1590,8 @@ struct Gcx
1591
1590
1592
1591
debug (INVARIANT ) initialized = false ;
1593
1592
1594
- for ( size_t i = 0 ; i < npools; i ++ )
1593
+ foreach (Pool * pool; this .pooltable[] )
1595
1594
{
1596
- Pool * pool = pooltable[i];
1597
1595
mappedPages -= pool.npages;
1598
1596
pool.Dtor();
1599
1597
cstdlib.free(pool);
@@ -1751,7 +1749,7 @@ struct Gcx
1751
1749
ConservativeGC._inFinalizer = true ;
1752
1750
scope (failure) ConservativeGC._inFinalizer = false ;
1753
1751
1754
- foreach (pool; pooltable[0 .. npools ])
1752
+ foreach (pool; this . pooltable[])
1755
1753
{
1756
1754
if (! pool.finals.nbits) continue ;
1757
1755
@@ -1993,7 +1991,7 @@ struct Gcx
1993
1991
1994
1992
bool tryAlloc () nothrow
1995
1993
{
1996
- foreach (p; pooltable[0 .. npools ])
1994
+ foreach (p; this . pooltable[])
1997
1995
{
1998
1996
if (! p.isLargeObject || p.freepages < npages)
1999
1997
continue ;
@@ -2093,10 +2091,11 @@ struct Gcx
2093
2091
}
2094
2092
2095
2093
// Allocate successively larger pools up to 8 megs
2096
- if (npools)
2097
- { size_t n;
2094
+ if (this .pooltable.length)
2095
+ {
2096
+ size_t n;
2098
2097
2099
- n = config.minPoolSize + config.incPoolSize * npools ;
2098
+ n = config.minPoolSize + config.incPoolSize * this .pooltable.length ;
2100
2099
if (n > config.maxPoolSize)
2101
2100
n = config.maxPoolSize; // cap pool size
2102
2101
n /= PAGESIZE ; // convert bytes to pages
@@ -2138,9 +2137,8 @@ struct Gcx
2138
2137
List* allocPage (Bins bin) nothrow
2139
2138
{
2140
2139
// debug(PRINTF) printf("Gcx::allocPage(bin = %d)\n", bin);
2141
- for ( size_t n = 0 ; n < npools; n ++ )
2140
+ foreach (Pool * pool; this .pooltable[] )
2142
2141
{
2143
- Pool* pool = pooltable[n];
2144
2142
if (pool.isLargeObject)
2145
2143
continue ;
2146
2144
if (List* p = (cast (SmallObjectPool* )pool).allocPage(bin))
@@ -2274,7 +2272,7 @@ struct Gcx
2274
2272
2275
2273
// let dmd allocate a register for this.pools
2276
2274
auto pools = pooltable.pools;
2277
- const highpool = pooltable.npools - 1 ;
2275
+ const highpool = pooltable.length - 1 ;
2278
2276
const minAddr = pooltable.minAddr;
2279
2277
size_t memSize = pooltable.maxAddr - minAddr;
2280
2278
Pool* pool = null ;
@@ -2524,9 +2522,8 @@ struct Gcx
2524
2522
{
2525
2523
debug (COLLECT_PRINTF ) printf(" preparing mark.\n " );
2526
2524
2527
- for ( size_t n = 0 ; n < npools; n ++ )
2525
+ foreach (Pool * pool; this .pooltable[] )
2528
2526
{
2529
- Pool* pool = pooltable[n];
2530
2527
if (pool.isLargeObject)
2531
2528
pool.mark.zero();
2532
2529
else
@@ -2596,10 +2593,9 @@ struct Gcx
2596
2593
size_t freedLargePages;
2597
2594
size_t freedSmallPages;
2598
2595
size_t freed;
2599
- for ( size_t n = 0 ; n < npools; n ++ )
2596
+ foreach (Pool * pool; this .pooltable[] )
2600
2597
{
2601
2598
size_t pn;
2602
- Pool* pool = pooltable[n];
2603
2599
2604
2600
if (pool.isLargeObject)
2605
2601
{
@@ -2787,7 +2783,8 @@ struct Gcx
2787
2783
2788
2784
assert (freedLargePages <= usedLargePages);
2789
2785
usedLargePages -= freedLargePages;
2790
- debug (COLLECT_PRINTF ) printf(" \t free'd %u bytes, %u pages from %u pools\n " , freed, freedLargePages, npools);
2786
+ debug (COLLECT_PRINTF ) printf(" \t free'd %u bytes, %u pages from %u pools\n " ,
2787
+ freed, freedLargePages, this .pooltable.length);
2791
2788
2792
2789
assert (freedSmallPages <= usedSmallPages);
2793
2790
usedSmallPages -= freedSmallPages;
@@ -2852,12 +2849,12 @@ struct Gcx
2852
2849
private SmallObjectPool* setNextRecoverPool (Bins bin, size_t poolIndex) nothrow
2853
2850
{
2854
2851
Pool* pool;
2855
- while (poolIndex < npools &&
2856
- ((pool = pooltable[poolIndex]).isLargeObject ||
2852
+ while (poolIndex < this .pooltable.length &&
2853
+ ((pool = this . pooltable[poolIndex]).isLargeObject ||
2857
2854
pool.recoverPageFirst[bin] >= pool.npages))
2858
2855
poolIndex++ ;
2859
2856
2860
- return recoverPool[bin] = poolIndex < npools ? cast (SmallObjectPool* )pool : null ;
2857
+ return recoverPool[bin] = poolIndex < this .pooltable.length ? cast (SmallObjectPool* )pool : null ;
2861
2858
}
2862
2859
2863
2860
version (COLLECT_FORK)
0 commit comments