summaryrefslogtreecommitdiffhomepage
path: root/src/vm.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-12-05 10:36:43 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2013-12-05 10:36:43 +0900
commit3c2f51aef24802c5e48eb33a4789adfe3a80f3c5 (patch)
tree90206a6c6c06f3b138e50741cc520d1909992d5e /src/vm.c
parent415ec6aca2c49338cab1c410e7c3a296ac928728 (diff)
downloadmruby-3c2f51aef24802c5e48eb33a4789adfe3a80f3c5.tar.gz
mruby-3c2f51aef24802c5e48eb33a4789adfe3a80f3c5.zip
remove unnecessary keep size adjustment in stack_extend_alloc(); close #1602
Diffstat (limited to 'src/vm.c')
-rw-r--r--src/vm.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/vm.c b/src/vm.c
index a600a2944..0d6318685 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -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);
}
}