1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/erb] Optimize away to_s if it's already T_STRING

[Feature #19102]https://github.com/ruby/erb/commit/38c6e182fb
This commit is contained in:
Takashi Kokubun 2022-11-03 23:26:53 -07:00 committed by git
parent dc5d06e9b1
commit 20efeaddbe

View file

@ -68,9 +68,9 @@ optimized_escape_html(VALUE str)
}
static VALUE
cgiesc_escape_html(VALUE self, VALUE str)
erb_escape_html(VALUE self, VALUE str)
{
StringValue(str);
str = rb_convert_type(str, T_STRING, "String", "to_s");
if (rb_enc_str_asciicompat_p(str)) {
return optimized_escape_html(str);
@ -80,13 +80,6 @@ cgiesc_escape_html(VALUE self, VALUE str)
}
}
static VALUE
erb_escape_html(VALUE self, VALUE str)
{
str = rb_funcall(str, rb_intern("to_s"), 0);
return cgiesc_escape_html(self, str);
}
void
Init_erb(void)
{