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

ruby-changes:65589

From: Nobuyoshi <ko1@a...>
Date: Sun, 21 Mar 2021 00:23:00 +0900 (JST)
Subject: [ruby-changes:65589] 298edfa4a2 (master): Refactor hash aset callback

https://git.ruby-lang.org/ruby.git/commit/?id=298edfa4a2

From 298edfa4a29d4233fda2b42abdf93a0cd74928b9 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 21 Mar 2021 00:11:08 +0900
Subject: Refactor hash aset callback

---
 hash.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/hash.c b/hash.c
index 378afa7..adbcf08 100644
--- a/hash.c
+++ b/hash.c
@@ -1672,6 +1672,8 @@ struct update_arg { https://github.com/ruby/ruby/blob/trunk/hash.c#L1672
     VALUE old_value;
 };
 
+static int hash_update_replace(st_data_t *key, st_data_t *value, struct update_arg *arg, int existing, st_data_t newvalue);
+
 typedef int (*tbl_update_func)(st_data_t *, st_data_t *, st_data_t, int);
 
 int
@@ -2837,16 +2839,7 @@ rb_hash_clear(VALUE hash) https://github.com/ruby/ruby/blob/trunk/hash.c#L2839
 static int
 hash_aset(st_data_t *key, st_data_t *val, struct update_arg *arg, int existing)
 {
-    if (existing) {
-	arg->new_value = arg->arg;
-	arg->old_value = *val;
-    }
-    else {
-	arg->new_key = *key;
-	arg->new_value = arg->arg;
-    }
-    *val = arg->arg;
-    return ST_CONTINUE;
+    return hash_update_replace(key, val, arg, existing, arg->arg);
 }
 
 VALUE
-- 
cgit v1.1


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

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