You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While I was working with config.action_view.frozen_string_literal in Rails (rails/rails#43725), I noticed that in some of our views we were still allocating identical strings repeatedly. I was kind of curious why, and noticed that it was due to our usage of view_component and string literals in view_component templates were not being frozen. As mentioned in the linked PR, the string literals can be significant parts of templates.
It would be neat to have the performance gain available here too!
Motivation
This would strictly be a performance improvement as I understand it.
The text was updated successfully, but these errors were encountered:
Hey @mitchellhenke, fantastic idea, thank you! We would welcome a PR that introduces this capability. I would look specifically to inject the # frozen_string_literal: true comment anywhere we're using class_eval in the compiler, for example here.
I verified that the magic comment works with class_eval as well as eval:
classFooclass_eval(<<~END) # frozen_string_literal: true def foo "foo" end ENDendirb> Foo.new.foo.frozen?=>true
Feature request
While I was working with
config.action_view.frozen_string_literal
in Rails (rails/rails#43725), I noticed that in some of our views we were still allocating identical strings repeatedly. I was kind of curious why, and noticed that it was due to our usage ofview_component
and string literals inview_component
templates were not being frozen. As mentioned in the linked PR, the string literals can be significant parts of templates.It would be neat to have the performance gain available here too!
Motivation
This would strictly be a performance improvement as I understand it.
The text was updated successfully, but these errors were encountered: