Skip to content

Commit 38c6e18

Browse files
committed
Optimize away to_s if it's already T_STRING
[Feature #19102]
1 parent ac9b219 commit 38c6e18

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

ext/erb/erb.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ optimized_escape_html(VALUE str)
6868
}
6969

7070
static VALUE
71-
cgiesc_escape_html(VALUE self, VALUE str)
71+
erb_escape_html(VALUE self, VALUE str)
7272
{
73-
StringValue(str);
73+
str = rb_convert_type(str, T_STRING, "String", "to_s");
7474

7575
if (rb_enc_str_asciicompat_p(str)) {
7676
return optimized_escape_html(str);
@@ -80,13 +80,6 @@ cgiesc_escape_html(VALUE self, VALUE str)
8080
}
8181
}
8282

83-
static VALUE
84-
erb_escape_html(VALUE self, VALUE str)
85-
{
86-
str = rb_funcall(str, rb_intern("to_s"), 0);
87-
return cgiesc_escape_html(self, str);
88-
}
89-
9083
void
9184
Init_erb(void)
9285
{

0 commit comments

Comments
 (0)