summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2022-09-08 14:07:43 +0200
committerJean Boussier <jean.boussier@gmail.com>2022-09-08 15:02:21 +0200
commitb7fa78b0f3c42d698aff7d6003d839febcbb4740 (patch)
tree42aa35e6ea6a34ae16e08edd5f49b4a9fb019218 /vm_insnhelper.c
parentcd1724bddeac5dd4c01ab0a2d527110fff9cf5f9 (diff)
vm_objtostring: skip method lookup for T_STRING receivers
We don't need it, and in string interpolation context that's the common case.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6334
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c9
1 files 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);
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