[前][次][番号順一覧][スレッド一覧]

ruby-changes:41983

From: nobu <ko1@a...>
Date: Wed, 9 Mar 2016 16:17:08 +0900 (JST)
Subject: [ruby-changes:41983] nobu:r54057 (trunk): hash.c: SET_DEFAULT

nobu	2016-03-09 16:17:03 +0900 (Wed, 09 Mar 2016)

  New Revision: 54057

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54057

  Log:
    hash.c: SET_DEFAULT
    
    * hash.c (SET_DEFAULT): new macro to set the default value.

  Modified files:
    trunk/hash.c
Index: hash.c
===================================================================
--- hash.c	(revision 54056)
+++ hash.c	(revision 54057)
@@ -32,6 +32,10 @@ https://github.com/ruby/ruby/blob/trunk/hash.c#L32
     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 https://github.com/ruby/ruby/blob/trunk/hash.c#L948
 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, VAL https://github.com/ruby/ruby/blob/trunk/hash.c#L996
 
     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");

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]