aboutsummaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-09 07:17:03 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-09 07:17:03 +0000
commit70d2b98dde0a0b8768026c983aba7cdd7fb2c52d (patch)
treee3ab63cddf1e61dd87721e4986380844404b8b2e /hash.c
parentf3eaba208f503c3228d7edaac73e473263c3675f (diff)
downloadruby-70d2b98dde0a0b8768026c983aba7cdd7fb2c52d.tar.gz
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.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/hash.c b/hash.c
index e98c7eec97..491aa17b23 100644
--- a/hash.c
+++ b/hash.c
@@ -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");