1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Set calling->kw_splat = 1 in vm_caller_setup_arg_kw

There are two styles that argv contains keyword arguments: one is
VM_CALL_KWARG which contains value elements in argv (to avoid a hash
object creation if possible), and the other is VM_CALL_KW_SPLAT which
contains one last hash in argv.

vm_caller_setup_arg_kw translates argv from the VM_CALL_KWARG style to
the VM_CALL_KW_SPLAT style.
`calling->kw_splat` means that argv is the VM_CALL_KW_SPLAT style.

So, instead of setting `calling->kw_splat` at many places, it would be
better to do so when vm_caller_setup_arg_kw is called.
This commit is contained in:
Yusuke Endoh 2019-09-05 12:28:36 +09:00 committed by Jeremy Evans
parent 1fffd33189
commit 030b8e5edf
2 changed files with 4 additions and 4 deletions

View file

@ -985,6 +985,7 @@ vm_caller_setup_arg_kw(rb_control_frame_t *cfp, struct rb_calling_info *calling,
cfp->sp -= kw_len - 1;
calling->argc -= kw_len - 1;
calling->kw_splat = 1;
}
static VALUE

View file

@ -2255,7 +2255,7 @@ vm_call_bmethod_body(rb_execution_context_t *ec, struct rb_calling_info *calling
/* control block frame */
GetProcPtr(cc->me->def->body.bmethod.proc, proc);
val = rb_vm_invoke_bmethod(ec, proc, calling->recv, calling->argc, argv, calling->kw_splat || (ci->flag & (VM_CALL_KWARG | VM_CALL_KW_SPLAT)), calling->block_handler, cc->me);
val = rb_vm_invoke_bmethod(ec, proc, calling->recv, calling->argc, argv, calling->kw_splat, calling->block_handler, cc->me);
return val;
}
@ -2412,8 +2412,7 @@ vm_call_method_missing(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp,
CALLER_SETUP_ARG(reg_cfp, calling, orig_ci, 0);
argc = calling->argc+1;
ci_entry.flag = VM_CALL_FCALL | VM_CALL_OPT_SEND |
(orig_ci->flag & (VM_CALL_KW_SPLAT |VM_CALL_KWARG) ? VM_CALL_KW_SPLAT : 0);
ci_entry.flag = VM_CALL_FCALL | VM_CALL_OPT_SEND | (orig_ci->flag & VM_CALL_KW_SPLAT);
ci_entry.mid = idMethodMissing;
ci_entry.orig_argc = argc;
ci = &ci_entry;
@ -3016,7 +3015,7 @@ vm_invoke_symbol_block(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp,
int argc;
CALLER_SETUP_ARG(ec->cfp, calling, ci, 0);
argc = calling->argc;
val = vm_yield_with_symbol(ec, symbol, argc, STACK_ADDR_FROM_TOP(argc), calling->kw_splat || (ci->flag & (VM_CALL_KWARG | VM_CALL_KW_SPLAT)), calling->block_handler);
val = vm_yield_with_symbol(ec, symbol, argc, STACK_ADDR_FROM_TOP(argc), calling->kw_splat, calling->block_handler);
POPN(argc);
return val;
}