[EXPERIMENTAL] Make Module#name return a frozen String

* Always the same frozen String for a given Module or Class.
    * Avoids extra allocations whenever calling Module#name.
    * See [Feature #16150]
This commit is contained in:
Jean Boussier 2019-09-26 10:41:43 +02:00 committed by Benoit Daloze
parent c8f7168653
commit 9d0866c7d7
Notes: git 2019-09-26 20:25:58 +09:00
3 changed files with 24 additions and 9 deletions

View file

@ -107,10 +107,7 @@ VALUE
rb_mod_name(VALUE mod)
{
int permanent;
VALUE path = classname(mod, &permanent);
if (!NIL_P(path)) return rb_str_dup(path);
return path;
return classname(mod, &permanent);
}
static VALUE