summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-09-13 16:42:27 -0700
committerJeremy Evans <code@jeremyevans.net>2019-09-13 16:42:27 -0700
commit3cfbfa9628435e3b09316a18c2db9e4f250fdd77 (patch)
treeaac052f5a518c9b4aaf296da2a4730c72e5ed521 /proc.c
parent24b1b339757ecab4539a2cb00a545bfcf885d3ef (diff)
Consolidate empty keyword handling
Remove rb_add_empty_keyword, and instead of calling that every place you need to add empty keyword hashes, run that code in a single static function in vm_eval.c. Add 4 defines to include/ruby/ruby.h, these are to be used as int kw_splat values when calling the various rb_*_kw functions: RB_NO_KEYWORDS :: Do not pass keywords RB_PASS_KEYWORDS :: Pass final argument (which should be hash) as keywords RB_PASS_EMPTY_KEYWORDS :: Add an empty hash to arguments and pass as keywords RB_PASS_CALLED_KEYWORDS :: Passes same keyword type as current method was called with (for method delegation) rb_empty_keyword_given_p needs to stay. It is required if argument delegation is done but delayed to a later point, which Enumerator does. Use RB_PASS_CALLED_KEYWORDS in rb_call_super to correctly delegate keyword arguments to super method.
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/proc.c b/proc.c
index 3c65d3d0ac..92264af2a7 100644
--- a/proc.c
+++ b/proc.c
@@ -2223,14 +2223,8 @@ call_method_data(rb_execution_context_t *ec, const struct METHOD *data,
int argc, const VALUE *argv, VALUE passed_procval)
{
vm_passed_block_handler_set(ec, proc_to_block_handler(passed_procval));
- if (rb_empty_keyword_given_p()) {
- return rb_vm_call_kw(ec, data->recv, data->me->called_id, argc+1, rb_add_empty_keyword(argc, argv),
- method_callable_method_entry(data), 1);
- }
- else {
- return rb_vm_call_kw(ec, data->recv, data->me->called_id, argc, argv,
- method_callable_method_entry(data), rb_keyword_given_p());
- }
+ return rb_vm_call_kw(ec, data->recv, data->me->called_id, argc, argv,
+ method_callable_method_entry(data), RB_PASS_CALLED_KEYWORDS);
}
static VALUE