diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-09 07:17:03 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-09 07:17:03 +0000 |
commit | 7522e064243e4d4c5f50fa906c2975328abaa545 (patch) | |
tree | e3ab63cddf1e61dd87721e4986380844404b8b2e /hash.c | |
parent | 921d6e269df182c3d9ab31f4bc084f5898d811e4 (diff) |
hash.c: SET_DEFAULT
* hash.c (SET_DEFAULT): new macro to set the default value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r-- | hash.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -32,6 +32,10 @@ FL_TEST((hash), FL_EXIVAR|FL_TAINT|HASH_PROC_DEFAULT) || \ !NIL_P(RHASH_IFNONE(hash))) +#define SET_DEFAULT(hash, ifnone) ( \ + FL_UNSET_RAW(hash, HASH_PROC_DEFAULT), \ + RHASH_SET_IFNONE(hash, ifnone)) + static VALUE has_extra_methods(VALUE klass) { @@ -944,8 +948,7 @@ static VALUE rb_hash_set_default(VALUE hash, VALUE ifnone) { rb_hash_modify_check(hash); - RHASH_SET_IFNONE(hash, ifnone); - FL_UNSET(hash, HASH_PROC_DEFAULT); + SET_DEFAULT(hash, ifnone); return ifnone; } @@ -993,8 +996,7 @@ rb_hash_set_default_proc(VALUE hash, VALUE proc) rb_hash_modify_check(hash); if (NIL_P(proc)) { - FL_UNSET(hash, HASH_PROC_DEFAULT); - RHASH_SET_IFNONE(hash, proc); + SET_DEFAULT(hash, proc); return proc; } b = rb_check_convert_type(proc, T_DATA, "Proc", "to_proc"); |