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:
parent
cd1724bdde
commit
b7fa78b0f3
Notes:
git
2022-09-08 22:02:54 +09:00
@ -4851,11 +4851,14 @@ VALUE rb_mod_name(VALUE);
|
|||||||
static VALUE
|
static VALUE
|
||||||
vm_objtostring(const rb_iseq_t *iseq, VALUE recv, CALL_DATA cd)
|
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);
|
const struct rb_callcache *cc = vm_search_method((VALUE)iseq, cd, recv);
|
||||||
|
|
||||||
switch (TYPE(recv)) {
|
switch (type) {
|
||||||
case T_STRING:
|
|
||||||
return recv;
|
|
||||||
case T_SYMBOL:
|
case T_SYMBOL:
|
||||||
if (check_cfunc(vm_cc_cme(cc), rb_sym_to_s)) {
|
if (check_cfunc(vm_cc_cme(cc), rb_sym_to_s)) {
|
||||||
// rb_sym_to_s() allocates a mutable string, but since we are only
|
// rb_sym_to_s() allocates a mutable string, but since we are only
|
||||||
|
Loading…
x
Reference in New Issue
Block a user