Commit 68468dab authored by Masaki Muranaka's avatar Masaki Muranaka

Extract stack zero filling to stack_clear(). Porting evelopers can optimize by...

Extract stack zero filling to stack_clear(). Porting evelopers can optimize by replacing to memset() on their own risk.
parent e70f9b35
......@@ -54,6 +54,16 @@ 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)
{
......@@ -128,15 +138,14 @@ stack_extend(mrb_state *mrb, int room, int keep)
}
if (room > keep) {
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;
stack_clear(&(mrb->stack[keep]), room - keep);
#else
int i;
for (i=keep; i<room; i++) {
SET_NIL_VALUE(mrb->stack[i]);
#endif
}
#endif
}
}
......
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