mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #1002 from monaka/pr-extract-stack-zero-filling
Extract stack zero filling into new function.
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user