Merge pull request #1002 from monaka/pr-extract-stack-zero-filling

Extract stack zero filling into new function.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2013-03-13 20:34:22 -07:00
+16 -9
View File
@@ -54,13 +54,21 @@ The value below allows about 60000 recursive calls in the simplest case. */
# define DEBUG(x)
#endif
static inline void
stack_clear(mrb_value *from, size_t count)
{
const mrb_value mrb_value_zero = { { 0 } };
while(count-- > 0) {
*from++ = mrb_value_zero;
}
}
static inline void
stack_copy(mrb_value *dst, const mrb_value *src, size_t size)
{
size_t i;
for (i = 0; i < size; i++) {
dst[i] = src[i];
while (size-- > 0) {
*dst++ = *src++;
}
}
@@ -130,15 +138,14 @@ stack_extend(mrb_state *mrb, int room, int keep)
}
if (room > keep) {
#ifndef MRB_NAN_BOXING
stack_clear(&(mrb->stack[keep]), room - keep);
#else
int i;
for (i=keep; i<room; i++) {
#ifndef MRB_NAN_BOXING
static const mrb_value mrb_value_zero = { { 0 } };
mrb->stack[i] = mrb_value_zero;
#else
SET_NIL_VALUE(mrb->stack[i]);
#endif
}
#endif
}
}