diff options
| author | Jean Boussier <jean.boussier@gmail.com> | 2026-05-17 13:35:47 +0300 |
|---|---|---|
| committer | Jean Boussier <jean.boussier@gmail.com> | 2026-05-17 20:15:21 +0300 |
| commit | 5eb42841443ed6a68371f9d79a43784897a0e6f6 (patch) | |
| tree | b2f685baef22263a4c84a147d3cf9a7a4d61cd07 | |
| parent | 6bc1aa31ccf39837bb0678da093b82f86a6534eb (diff) | |
Stop using `rb_class_path_cached`, and deprecate it.
That API made sense before b00f280d4b9569e7153365d7e1c522b3d6b3c6cf
as finding a module name was costly, but it now is a very cheap
operation, and that function is now just an outdated alias.
| -rw-r--r-- | ext/objspace/object_tracing.c | 2 | ||||
| -rw-r--r-- | gc.c | 8 | ||||
| -rw-r--r-- | include/ruby/internal/intern/variable.h | 1 | ||||
| -rw-r--r-- | vm.c | 2 |
4 files changed, 7 insertions, 6 deletions
diff --git a/ext/objspace/object_tracing.c b/ext/objspace/object_tracing.c index c06f1f68dd..1c18bf02ee 100644 --- a/ext/objspace/object_tracing.c +++ b/ext/objspace/object_tracing.c @@ -91,7 +91,7 @@ newobj_i(VALUE tpval, void *data) VALUE klass = rb_tracearg_defined_class(tparg); struct allocation_info *info; const char *path_cstr = RTEST(path) ? make_unique_str(arg->str_table, RSTRING_PTR(path), RSTRING_LEN(path)) : 0; - VALUE class_path = (RTEST(klass) && !OBJ_FROZEN(klass)) ? rb_class_path_cached(klass) : Qnil; + VALUE class_path = (RTEST(klass) && !OBJ_FROZEN(klass)) ? rb_mod_name(klass) : Qnil; const char *class_path_cstr = RTEST(class_path) ? make_unique_str(arg->str_table, RSTRING_PTR(class_path), RSTRING_LEN(class_path)) : 0; st_data_t v; @@ -4960,7 +4960,7 @@ rb_raw_obj_info_common(char *const buff, const size_t buff_size, const VALUE obj APPEND_S("(temporary internal)"); } else if (RTEST(RBASIC(obj)->klass)) { - VALUE class_path = rb_class_path_cached(RBASIC(obj)->klass); + VALUE class_path = rb_mod_name(RBASIC(obj)->klass); if (!NIL_P(class_path)) { APPEND_F("%s ", RSTRING_PTR(class_path)); } @@ -5046,7 +5046,7 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU case T_CLASS: case T_MODULE: { - VALUE class_path = rb_class_path_cached(obj); + VALUE class_path = rb_mod_name(obj); if (!NIL_P(class_path)) { APPEND_F("%s", RSTRING_PTR(class_path)); } @@ -5057,7 +5057,7 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU } case T_ICLASS: { - VALUE class_path = rb_class_path_cached(RBASIC_CLASS(obj)); + VALUE class_path = rb_mod_name(RBASIC_CLASS(obj)); if (!NIL_P(class_path)) { APPEND_F("src:%s", RSTRING_PTR(class_path)); } @@ -5148,7 +5148,7 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU case imemo_callcache: { const struct rb_callcache *cc = (const struct rb_callcache *)obj; - VALUE class_path = vm_cc_valid(cc) ? rb_class_path_cached(cc->klass) : Qnil; + VALUE class_path = vm_cc_valid(cc) ? rb_mod_name(cc->klass) : Qnil; const rb_callable_method_entry_t *cme = vm_cc_cme(cc); APPEND_F("(klass:%s cme:%s%s (%p) call:%p", diff --git a/include/ruby/internal/intern/variable.h b/include/ruby/internal/intern/variable.h index 479c3950c1..315584790c 100644 --- a/include/ruby/internal/intern/variable.h +++ b/include/ruby/internal/intern/variable.h @@ -48,6 +48,7 @@ VALUE rb_mod_name(VALUE mod); */ VALUE rb_class_path(VALUE mod); +RBIMPL_ATTR_DEPRECATED(("rb_mod_name")) /** * @alias{rb_mod_name} * @@ -4290,7 +4290,7 @@ Init_VM(void) /* FrozenCore (hidden) */ fcore = rb_class_new(rb_cBasicObject); rb_set_class_path(fcore, rb_cRubyVM, "FrozenCore"); - rb_vm_register_global_object(rb_class_path_cached(fcore)); + rb_vm_register_global_object(rb_mod_name(fcore)); klass = rb_singleton_class(fcore); rb_define_method_id(klass, id_core_set_method_alias, m_core_set_method_alias, 3); rb_define_method_id(klass, id_core_set_variable_alias, m_core_set_variable_alias, 2); |
