Extract stack zero filling to stack_clear(). Porting evelopers can optimize by replacing to memset() on their own risk.

This commit is contained in:
Masaki Muranaka
2013-03-13 18:26:59 +09:00
parent e70f9b351d
commit 68468dabfa
+14 -5
View File
@@ -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) {
#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
}
}