Fix vm_objtostring optimization for Symbol

Co-authored-by: John Hawthorn <john@hawthorn.email>
This commit is contained in:
Maximillian Polhill 2024-11-25 14:29:55 -05:00 committed by John Hawthorn
parent 36f67f6bbb
commit 56fbf64a53
Notes: git 2024-11-26 01:30:24 +00:00

View File

@ -2338,6 +2338,12 @@ check_cfunc(const rb_callable_method_entry_t *me, cfunc_type func)
}
}
static inline int
check_method_basic_definition(const rb_callable_method_entry_t *me)
{
return me && METHOD_ENTRY_BASIC(me);
}
static inline int
vm_method_cfunc_is(const rb_iseq_t *iseq, CALL_DATA cd, VALUE recv, cfunc_type func)
{
@ -6072,7 +6078,7 @@ vm_objtostring(const rb_iseq_t *iseq, VALUE recv, CALL_DATA cd)
switch (type) {
case T_SYMBOL:
if (check_cfunc(vm_cc_cme(cc), rb_sym_to_s)) {
if (check_method_basic_definition(vm_cc_cme(cc))) {
// rb_sym_to_s() allocates a mutable string, but since we are only
// going to use this string for interpolation, it's fine to use the
// frozen string.