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

ruby-changes:42736

From: nobu <ko1@a...>
Date: Thu, 28 Apr 2016 16:06:43 +0900 (JST)
Subject: [ruby-changes:42736] nobu:r54810 (trunk): hash.c: dry up code

nobu	2016-04-28 17:03:19 +0900 (Thu, 28 Apr 2016)

  New Revision: 54810

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

  Log:
    hash.c: dry up code
    
    * hash.c (rb_hash_update_{block,func}_callback): dry up hash
      update callback code.  [Fix GH-1338]

  Modified files:
    trunk/ChangeLog
    trunk/hash.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 54809)
+++ ChangeLog	(revision 54810)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Apr 28 17:03:17 2016  Nicholas Maccharoli  <nmaccharoli@g...>
+
+	* hash.c (rb_hash_update_{block,func}_callback): dry up hash
+	  update callback code.  [Fix GH-1338]
+
 Thu Apr 28 16:52:05 2016  NARUSE, Yui  <naruse@r...>
 
 	* re.c (rb_reg_prepare_enc): use rb_enc_asciicompat(enc) instead of
Index: hash.c
===================================================================
--- hash.c	(revision 54809)
+++ hash.c	(revision 54810)
@@ -2291,12 +2291,11 @@ rb_hash_update_block_callback(st_data_t https://github.com/ruby/ruby/blob/trunk/hash.c#L2291
     if (existing) {
 	newvalue = rb_yield_values(3, (VALUE)*key, (VALUE)*value, newvalue);
 	arg->old_value = *value;
-	arg->new_value = newvalue;
     }
     else {
 	arg->new_key = *key;
-	arg->new_value = newvalue;
     }
+    arg->new_value = newvalue;
     *value = newvalue;
     return ST_CONTINUE;
 }
@@ -2362,12 +2361,11 @@ rb_hash_update_func_callback(st_data_t * https://github.com/ruby/ruby/blob/trunk/hash.c#L2361
     if (existing) {
 	newvalue = (*uf_arg->func)((VALUE)*key, (VALUE)*value, newvalue);
 	arg->old_value = *value;
-	arg->new_value = newvalue;
     }
     else {
 	arg->new_key = *key;
-	arg->new_value = newvalue;
     }
+    arg->new_value = newvalue;
     *value = newvalue;
     return ST_CONTINUE;
 }

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

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