Skip to content

Commit

Permalink
Reduce String allocations when building Action View tags
Browse files Browse the repository at this point in the history
This method is called against each tag option for each tag,
and creates an extra garbage String per each call
  • Loading branch information
amatsuda committed Apr 26, 2018
1 parent ac93e7b commit 9276ea8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion actionview/lib/action_view/helpers/tag_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def tag_option(key, value, escape)
else
value = escape ? ERB::Util.unwrapped_html_escape(value) : value.to_s
end
%(#{key}="#{value.gsub('"'.freeze, '"'.freeze)}")
value.gsub!('"'.freeze, '"'.freeze)
%(#{key}="#{value}")
end

private
Expand Down

0 comments on commit 9276ea8

Please sign in to comment.