summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2022-11-15 10:52:39 -0500
committerPeter Zhu <peter@peterzhu.ca>2022-11-21 09:58:53 -0500
commit648927d71bde5df02a0490f5f45bb7fcde913376 (patch)
treecb89cd7440e51d374e3e6346e1a0d72514532a3c /object.c
parent612aa5c24a7c249867bbcd7d6567012aa6a7f4b9 (diff)
downloadruby-648927d71bde5df02a0490f5f45bb7fcde913376.tar.gz
Refactor obj_ivar_set and vm_setivar
obj_ivar_set and vm_setivar_slowpath is essentially doing the same thing, but the code is duplicated and not quite implemented in the same way, which could cause bugs. This commit refactors vm_setivar_slowpath to use obj_ivar_set.
Diffstat (limited to 'object.c')
-rw-r--r--object.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/object.c b/object.c
index eae5a43088..ac59b74301 100644
--- a/object.c
+++ b/object.c
@@ -2790,7 +2790,7 @@ rb_obj_ivar_get(VALUE obj, VALUE iv)
*/
static VALUE
-rb_obj_ivar_set(VALUE obj, VALUE iv, VALUE val)
+rb_obj_ivar_set_m(VALUE obj, VALUE iv, VALUE val)
{
ID id = id_for_var(obj, iv, instance);
if (!id) id = rb_intern_str(iv);
@@ -4399,7 +4399,7 @@ InitVM_Object(void)
rb_define_method(rb_mKernel, "public_methods", rb_obj_public_methods, -1); /* in class.c */
rb_define_method(rb_mKernel, "instance_variables", rb_obj_instance_variables, 0); /* in variable.c */
rb_define_method(rb_mKernel, "instance_variable_get", rb_obj_ivar_get, 1);
- rb_define_method(rb_mKernel, "instance_variable_set", rb_obj_ivar_set, 2);
+ rb_define_method(rb_mKernel, "instance_variable_set", rb_obj_ivar_set_m, 2);
rb_define_method(rb_mKernel, "instance_variable_defined?", rb_obj_ivar_defined, 1);
rb_define_method(rb_mKernel, "remove_instance_variable",
rb_obj_remove_instance_variable, 1); /* in variable.c */