remove unnecessary keep size adjustment in stack_extend_alloc(); close #1602

This commit is contained in:
Yukihiro "Matz" Matsumoto
2013-12-05 10:36:43 +09:00
parent 415ec6aca2
commit 3c2f51aef2
+4 -6
View File
@@ -132,17 +132,14 @@ envadjust(mrb_state *mrb, mrb_value *oldbase, mrb_value *newbase)
/** def rec ; $deep =+ 1 ; if $deep > 1000 ; return 0 ; end ; rec ; end */
static void
stack_extend_alloc(mrb_state *mrb, int room, int keep)
stack_extend_alloc(mrb_state *mrb, int room)
{
mrb_value *oldbase = mrb->c->stbase;
int size = mrb->c->stend - mrb->c->stbase;
int off = mrb->c->stack - mrb->c->stbase;
/* do not leave uninitialized malloc region */
if (keep > size) keep = size;
/* Use linear stack growth.
It is slightly slower than doubling thestack space,
It is slightly slower than doubling the stack space,
but it saves memory on small devices. */
if (room <= size)
size += MRB_STACK_GROWTH;
@@ -164,9 +161,10 @@ static inline void
stack_extend(mrb_state *mrb, int room, int keep)
{
if (mrb->c->stack + room >= mrb->c->stend) {
stack_extend_alloc(mrb, room, keep);
stack_extend_alloc(mrb, room);
}
if (room > keep) {
/* do not leave uninitialized malloc region */
stack_clear(&(mrb->c->stack[keep]), room - keep);
}
}