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

ruby-changes:57860

From: Yusuke <ko1@a...>
Date: Sun, 22 Sep 2019 17:01:14 +0900 (JST)
Subject: [ruby-changes:57860] 28eefb33c8 (master): variable.c: Rename rb_st_copy to rb_iv_tbl_copy

https://git.ruby-lang.org/ruby.git/commit/?id=28eefb33c8

From 28eefb33c8d27e5711319873d065e5414d7ffe25 Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Sun, 22 Sep 2019 16:21:26 +0900
Subject: variable.c: Rename rb_st_copy to rb_iv_tbl_copy

This function was created as a variant of st_copy with firing write
barrier.
It should have more explicit name, such as st_copy_with_write_barrier.
But because it is used only for copying iv_tbl, so I rename it to
rb_iv_tbl_copy now.  If we face other use case than iv_tbl, we may want
to rename it to more general name.

diff --git a/class.c b/class.c
index 6b3b662..08e0539 100644
--- a/class.c
+++ b/class.c
@@ -341,7 +341,7 @@ rb_mod_init_copy(VALUE clone, VALUE orig) https://github.com/ruby/ruby/blob/trunk/class.c#L341
     if (RCLASS_IV_TBL(orig)) {
 	st_data_t id;
 
-	RCLASS_IV_TBL(clone) = rb_st_copy(clone, RCLASS_IV_TBL(orig));
+	rb_iv_tbl_copy(clone, orig);
 	CONST_ID(id, "__tmp_classpath__");
 	st_delete(RCLASS_IV_TBL(clone), &id, 0);
 	CONST_ID(id, "__classpath__");
@@ -394,7 +394,7 @@ rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach) https://github.com/ruby/ruby/blob/trunk/class.c#L394
 	RCLASS_SET_SUPER(clone, RCLASS_SUPER(klass));
 	RCLASS_EXT(clone)->allocator = RCLASS_EXT(klass)->allocator;
 	if (RCLASS_IV_TBL(klass)) {
-	    RCLASS_IV_TBL(clone) = rb_st_copy(clone, RCLASS_IV_TBL(klass));
+	    rb_iv_tbl_copy(clone, klass);
 	}
 	if (RCLASS_CONST_TBL(klass)) {
 	    struct clone_const_arg arg;
diff --git a/internal.h b/internal.h
index 6845ba8..b000fee 100644
--- a/internal.h
+++ b/internal.h
@@ -2519,7 +2519,7 @@ void rb_mark_generic_ivar(VALUE); https://github.com/ruby/ruby/blob/trunk/internal.h#L2519
 void rb_mv_generic_ivar(VALUE src, VALUE dst);
 VALUE rb_const_missing(VALUE klass, VALUE name);
 int rb_class_ivar_set(VALUE klass, ID vid, VALUE value);
-st_table *rb_st_copy(VALUE obj, struct st_table *orig_tbl);
+void rb_iv_tbl_copy(VALUE dst, VALUE src);
 
 /* gc.c (export) */
 VALUE rb_wb_protected_newobj_of(VALUE, VALUE);
diff --git a/variable.c b/variable.c
index 1627467..9fd075c 100644
--- a/variable.c
+++ b/variable.c
@@ -3360,12 +3360,13 @@ tbl_copy_i(st_data_t key, st_data_t value, st_data_t data) https://github.com/ruby/ruby/blob/trunk/variable.c#L3360
     return ST_CONTINUE;
 }
 
-st_table *
-rb_st_copy(VALUE obj, struct st_table *orig_tbl)
+void
+rb_iv_tbl_copy(VALUE dst, VALUE src)
 {
+    st_table *orig_tbl = RCLASS_IV_TBL(src);
     st_table *new_tbl = st_copy(orig_tbl);
-    st_foreach(new_tbl, tbl_copy_i, (st_data_t)obj);
-    return new_tbl;
+    st_foreach(new_tbl, tbl_copy_i, (st_data_t)dst);
+    RCLASS_IV_TBL(dst) = new_tbl;
 }
 
 MJIT_FUNC_EXPORTED rb_const_entry_t *
-- 
cgit v0.10.2


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

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