summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-03 23:56:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-07-03 23:56:11 +0000
commitaec14b33d4379d69b63766964ac731fc3cb42edf (patch)
treeba8a84b5162cd36c4dedab538c0c951168336024 /vm.c
parent8d004ee5fb025c854451544a369740dc4598cbf5 (diff)
vm.c: simplified core#hash_merge_kwd
* vm.c (core_hash_merge_kwd): simplified to merge the second hash into the first hash. * compile.c (compile_array): call core#hash_merge_kwd with 2 hashes always, by passing an new empty hash to at the first iteration. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/vm.c b/vm.c
index efdbff9..112f4de 100644
--- a/vm.c
+++ b/vm.c
@@ -2675,7 +2675,7 @@ m_core_set_postexe(VALUE self)
static VALUE core_hash_merge_ary(VALUE hash, VALUE ary);
static VALUE core_hash_from_ary(VALUE ary);
-static VALUE core_hash_merge_kwd(int argc, VALUE *argv);
+static VALUE core_hash_merge_kwd(VALUE hash, VALUE kw);
static VALUE
core_hash_merge(VALUE hash, long argc, const VALUE *argv)
@@ -2746,30 +2746,17 @@ kwmerge_i(VALUE key, VALUE value, VALUE hash)
return ST_CONTINUE;
}
-static int
-kwcheck_i(VALUE key, VALUE value, VALUE hash)
-{
- kw_check_symbol(key);
- return ST_CONTINUE;
-}
-
static VALUE
-m_core_hash_merge_kwd(int argc, VALUE *argv, VALUE recv)
+m_core_hash_merge_kwd(VALUE recv, VALUE hash, VALUE kw)
{
- VALUE hash;
- REWIND_CFP(hash = core_hash_merge_kwd(argc, argv));
+ REWIND_CFP(hash = core_hash_merge_kwd(hash, kw));
return hash;
}
static VALUE
-core_hash_merge_kwd(int argc, VALUE *argv)
-{
- VALUE hash, kw;
- rb_check_arity(argc, 1, 2);
- hash = argv[0];
- kw = rb_to_hash_type(argv[argc-1]);
- if (argc < 2) hash = kw;
- rb_hash_foreach(kw, argc < 2 ? kwcheck_i : kwmerge_i, hash);
+core_hash_merge_kwd(VALUE hash, VALUE kw)
+{
+ rb_hash_foreach(rb_to_hash_type(kw), kwmerge_i, hash);
return hash;
}
@@ -2859,7 +2846,7 @@ Init_VM(void)
rb_define_method_id(klass, id_core_hash_merge_ary, m_core_hash_merge_ary, 2);
#endif
rb_define_method_id(klass, id_core_hash_merge_ptr, m_core_hash_merge_ptr, -1);
- rb_define_method_id(klass, id_core_hash_merge_kwd, m_core_hash_merge_kwd, -1);
+ rb_define_method_id(klass, id_core_hash_merge_kwd, m_core_hash_merge_kwd, 2);
rb_define_method_id(klass, idProc, rb_block_proc, 0);
rb_define_method_id(klass, idLambda, rb_block_lambda, 0);
rb_obj_freeze(fcore);