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

parent 415ec6ac
...@@ -132,17 +132,14 @@ envadjust(mrb_state *mrb, mrb_value *oldbase, mrb_value *newbase) ...@@ -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 */ /** def rec ; $deep =+ 1 ; if $deep > 1000 ; return 0 ; end ; rec ; end */
static void 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; mrb_value *oldbase = mrb->c->stbase;
int size = mrb->c->stend - mrb->c->stbase; int size = mrb->c->stend - mrb->c->stbase;
int off = mrb->c->stack - 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. /* 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. */ but it saves memory on small devices. */
if (room <= size) if (room <= size)
size += MRB_STACK_GROWTH; size += MRB_STACK_GROWTH;
...@@ -164,9 +161,10 @@ static inline void ...@@ -164,9 +161,10 @@ static inline void
stack_extend(mrb_state *mrb, int room, int keep) stack_extend(mrb_state *mrb, int room, int keep)
{ {
if (mrb->c->stack + room >= mrb->c->stend) { if (mrb->c->stack + room >= mrb->c->stend) {
stack_extend_alloc(mrb, room, keep); stack_extend_alloc(mrb, room);
} }
if (room > keep) { if (room > keep) {
/* do not leave uninitialized malloc region */
stack_clear(&(mrb->c->stack[keep]), room - keep); stack_clear(&(mrb->c->stack[keep]), room - keep);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment