Skip to content

Commit

Permalink
Avoid allocating new string when output_postamble is blank
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellhenke committed Nov 27, 2023
1 parent bfee458 commit 38077f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ nav_order: 5

## main

* Avoid duplicating rendered string when `output_postamble` is blank

*Mitchell Henke*

* Remove unsupported versions of Rails & Ruby from CI matrix.

*Reegan Viljoen*
Expand Down
6 changes: 5 additions & 1 deletion lib/view_component/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ def render_in(view_context, &block)
before_render

if render?
render_template_for(@__vc_variant).to_s + output_postamble
if output_postamble.blank?
render_template_for(@__vc_variant).to_s
else
render_template_for(@__vc_variant).to_s + output_postamble
end
else
""
end
Expand Down

0 comments on commit 38077f6

Please sign in to comment.