Skip to content

Commit

Permalink
op.c: Make slabs sizes powers of two
Browse files Browse the repository at this point in the history
It wasn’t exactly doubling the size of the previous slab, but making
it two less than that.  I’m assuming that malloc implementations round
things up to powers of two, and trying to take advantage of that, so
we don’t have wasted gaps at the ends of slabs.
  • Loading branch information
Father Chrysostomos committed Jul 12, 2012
1 parent 90519d0 commit af7751f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions op.c
Expand Up @@ -222,9 +222,10 @@ Perl_Slab_Alloc(pTHX_ size_t sz)
/* Create a new slab. Make this one twice as big. */
slot = slab2->opslab_first;
while (slot->opslot_next) slot = slot->opslot_next;
slab2 = S_new_slab(aTHX_ DIFF(slab2, slot)*2 > PERL_MAX_SLAB_SIZE
slab2 = S_new_slab(aTHX_
(DIFF(slab2, slot)+1)*2 > PERL_MAX_SLAB_SIZE
? PERL_MAX_SLAB_SIZE
: DIFF(slab2, slot)*2);
: (DIFF(slab2, slot)+1)*2);
slab2->opslab_next = slab->opslab_next;
slab->opslab_next = slab2;
}
Expand Down

0 comments on commit af7751f

Please sign in to comment.