From 458d6fb15eedaa142c71f120e3a71b84d0938454 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sat, 5 Nov 2022 00:41:52 -0700 Subject: [PATCH] [ruby/erb] Optimize away the rb_convert_type call using RB_TYPE_P https://github.com/ruby/erb/commit/12058c3784 --- ext/erb/erb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/erb/erb.c b/ext/erb/erb.c index 1c3371d24e..a103fb30e4 100644 --- a/ext/erb/erb.c +++ b/ext/erb/erb.c @@ -76,7 +76,9 @@ optimized_escape_html(VALUE str) static VALUE erb_escape_html(VALUE self, VALUE str) { - str = rb_convert_type(str, T_STRING, "String", "to_s"); + if (!RB_TYPE_P(str, T_STRING)) { + str = rb_convert_type(str, T_STRING, "String", "to_s"); + } if (rb_enc_str_asciicompat_p(str)) { return optimized_escape_html(str);