diff options
Diffstat (limited to 'vm_args.c')
-rw-r--r-- | vm_args.c | 37 |
1 files changed, 12 insertions, 25 deletions
@@ -571,22 +571,6 @@ check_kwrestarg(VALUE keyword_hash, unsigned int *kw_flag) } } -static void -flatten_rest_args(rb_execution_context_t * const ec, struct args_info *args, VALUE * const locals, unsigned int *ci_flag) -{ - const VALUE *argv = RARRAY_CONST_PTR(args->rest); - int j, i=args->argc, rest_len = RARRAY_LENINT(args->rest)-1; - args->argc += rest_len; - if (rest_len) { - CHECK_VM_STACK_OVERFLOW(ec->cfp, rest_len+1); - for (i, j=0; rest_len > 0; rest_len--, i++, j++) { - locals[i] = argv[j]; - } - } - args->rest = Qfalse; - *ci_flag &= ~VM_CALL_ARGS_SPLAT; -} - static int setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * const iseq, struct rb_calling_info *const calling, @@ -743,24 +727,27 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co args->rest_dupped = false; if (ignore_keyword_hash_p(rest_last, iseq, &kw_flag, &converted_keyword_hash)) { - if (ISEQ_BODY(iseq)->param.flags.has_rest) { + if (ISEQ_BODY(iseq)->param.flags.has_rest || arg_setup_type != arg_setup_method) { // Only duplicate/modify splat array if it will be used arg_rest_dup(args); rb_ary_pop(args->rest); } - else if (arg_setup_type == arg_setup_block && !ISEQ_BODY(iseq)->param.flags.has_kwrest) { - // Avoid hash allocation for empty hashes - // Copy rest elements except empty keyword hash directly to VM stack - flatten_rest_args(ec, args, locals, &ci_flag); - keyword_hash = Qnil; - kw_flag = 0; - } given_argc--; } else if (!ISEQ_BODY(iseq)->param.flags.has_rest) { // Avoid duping rest when not necessary // Copy rest elements and converted keyword hash directly to VM stack - flatten_rest_args(ec, args, locals, &ci_flag); + const VALUE *argv = RARRAY_CONST_PTR(args->rest); + int j, i=args->argc, rest_len = RARRAY_LENINT(args->rest)-1; + args->argc += rest_len; + if (rest_len) { + CHECK_VM_STACK_OVERFLOW(ec->cfp, rest_len+1); + for (i, j=0; rest_len > 0; rest_len--, i++, j++) { + locals[i] = argv[j]; + } + } + args->rest = Qfalse; + ci_flag &= ~VM_CALL_ARGS_SPLAT; if (ISEQ_BODY(iseq)->param.flags.has_kw || ISEQ_BODY(iseq)->param.flags.has_kwrest) { given_argc--; |