Skip to content

Commit e0944bd

Browse files
committed
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.
1 parent 526d0f4 commit e0944bd

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

class.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,7 @@ rb_module_new(void)
859859
return (VALUE)mdl;
860860
}
861861

862+
// Kept for compatibility. Use rb_module_new() instead.
862863
VALUE
863864
rb_define_module_id(ID id)
864865
{
@@ -882,7 +883,7 @@ rb_define_module(const char *name)
882883
rb_vm_add_root_module(module);
883884
return module;
884885
}
885-
module = rb_define_module_id(id);
886+
module = rb_module_new();
886887
rb_vm_add_root_module(module);
887888
rb_const_set(rb_cObject, id, module);
888889

@@ -909,7 +910,7 @@ rb_define_module_id_under(VALUE outer, ID id)
909910
}
910911
return module;
911912
}
912-
module = rb_define_module_id(id);
913+
module = rb_module_new();
913914
rb_const_set(outer, id, module);
914915
rb_set_class_path_string(module, outer, rb_id2str(id));
915916
rb_gc_register_mark_object(module);

vm_insnhelper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4043,7 +4043,7 @@ static VALUE
40434043
vm_declare_module(ID id, VALUE cbase)
40444044
{
40454045
/* new module declaration */
4046-
return declare_under(id, cbase, rb_define_module_id(id));
4046+
return declare_under(id, cbase, rb_module_new());
40474047
}
40484048

40494049
NORETURN(static void unmatched_redefinition(const char *type, VALUE cbase, ID id, VALUE old));

0 commit comments

Comments
 (0)