ruby-changes:73483
From: Jean <ko1@a...>
Date: Thu, 8 Sep 2022 22:02:49 +0900 (JST)
Subject: [ruby-changes:73483] b7fa78b0f3 (master): vm_objtostring: skip method lookup for T_STRING receivers
https://git.ruby-lang.org/ruby.git/commit/?id=b7fa78b0f3 From b7fa78b0f3c42d698aff7d6003d839febcbb4740 Mon Sep 17 00:00:00 2001 From: Jean Boussier <jean.boussier@g...> Date: Thu, 8 Sep 2022 14:07:43 +0200 Subject: vm_objtostring: skip method lookup for T_STRING receivers We don't need it, and in string interpolation context that's the common case. --- vm_insnhelper.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 9ccfdff4a0..c68872a9bf 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -4851,11 +4851,14 @@ VALUE rb_mod_name(VALUE); https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L4851 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 -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/