ruby-changes:63754
From: Alan <ko1@a...>
Date: Thu, 26 Nov 2020 07:06:54 +0900 (JST)
Subject: [ruby-changes:63754] e0944bde91 (master): Prefer rb_module_new() over rb_define_module_id()
https://git.ruby-lang.org/ruby.git/commit/?id=e0944bde91 From e0944bde9178fda7281717a159d0ffbfd3154f47 Mon Sep 17 00:00:00 2001 From: Alan Wu <alanwu@r...> Date: Wed, 25 Nov 2020 17:05:06 -0500 Subject: Prefer rb_module_new() over rb_define_module_id() rb_define_module_id() doesn't do anything with its parameter so it's a bit confusing. diff --git a/class.c b/class.c index 1f56385..45c9c6a 100644 --- a/class.c +++ b/class.c @@ -859,6 +859,7 @@ rb_module_new(void) https://github.com/ruby/ruby/blob/trunk/class.c#L859 return (VALUE)mdl; } +// Kept for compatibility. Use rb_module_new() instead. VALUE rb_define_module_id(ID id) { @@ -882,7 +883,7 @@ rb_define_module(const char *name) https://github.com/ruby/ruby/blob/trunk/class.c#L883 rb_vm_add_root_module(module); return module; } - module = rb_define_module_id(id); + module = rb_module_new(); rb_vm_add_root_module(module); rb_const_set(rb_cObject, id, module); @@ -909,7 +910,7 @@ rb_define_module_id_under(VALUE outer, ID id) https://github.com/ruby/ruby/blob/trunk/class.c#L910 } return module; } - module = rb_define_module_id(id); + module = rb_module_new(); rb_const_set(outer, id, module); rb_set_class_path_string(module, outer, rb_id2str(id)); rb_gc_register_mark_object(module); diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 4f5d18a..b6ad18c 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -4043,7 +4043,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L4043 vm_declare_module(ID id, VALUE cbase) { /* new module declaration */ - return declare_under(id, cbase, rb_define_module_id(id)); + return declare_under(id, cbase, rb_module_new()); } NORETURN(static void unmatched_redefinition(const char *type, VALUE cbase, ID id, VALUE old)); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/