mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Extract stack zero filling to stack_clear(). Porting evelopers can optimize by replacing to memset() on their own risk.
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user