Skip to content

Commit

Permalink
prepend string to avoid a small allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellhenke committed Nov 9, 2023
1 parent cbac21b commit ec74a77
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/view_component/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def call
SOURCE
# rubocop:disable Style/EvalWithLocation
if frozen_string_literal
component_class.class_eval("# frozen_string_literal: true\n#{source}", template.path, template.lineno - 1)
component_class.class_eval(source.prepend("# frozen_string_literal: true\n"), template.path, template.lineno - 1)
else
component_class.class_eval(source, template.path, template.lineno)
end
Expand Down Expand Up @@ -83,7 +83,7 @@ def #{method_name}
SOURCE
# rubocop:disable Style/EvalWithLocation
if frozen_string_literal
component_class.class_eval("# frozen_string_literal: true\n#{source}", template[:path], -1)
component_class.class_eval(source.prepend("# frozen_string_literal: true\n"), template[:path], -1)
else
component_class.class_eval(source, template[:path], 0)
end
Expand Down

0 comments on commit ec74a77

Please sign in to comment.