1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

vm_objtostring: skip method lookup for T_STRING receivers

We don't need it, and in string interpolation context
that's the common case.
This commit is contained in:
Jean Boussier 2022-09-08 14:07:43 +02:00
parent cd1724bdde
commit b7fa78b0f3
Notes: git 2022-09-08 22:02:54 +09:00

View file

@ -4851,11 +4851,14 @@ VALUE rb_mod_name(VALUE);
static VALUE
vm_objtostring(const rb_iseq_t *iseq, VALUE recv, CALL_DATA cd)
{
int type = TYPE(recv);
if (type == T_STRING) {
return recv;
}
const struct rb_callcache *cc = vm_search_method((VALUE)iseq, cd, recv);
switch (TYPE(recv)) {
case T_STRING:
return recv;
switch (type) {
case T_SYMBOL:
if (check_cfunc(vm_cc_cme(cc), rb_sym_to_s)) {
// rb_sym_to_s() allocates a mutable string, but since we are only