Perf: Remove unneeded to_s and freeze strings

- No longer call to_s on string literals passed to undefined filters
- Freeze all string literals at the top of the generated code

This shows a ~9% performance improvement on the fluid benchmark when run without YJIT
This commit is contained in:
Sam Doiron
2022-04-20 11:03:36 -03:00
parent 7c70b56002
commit ba82f8d05e
2 changed files with 16 additions and 22 deletions
-8
View File
@@ -18,14 +18,6 @@ Liquid::Template.register_filter(ShopFilter)
context = Liquid::Context.new([tables, {}], {}, {}, false, Liquid::ResourceLimits.new(Liquid::Template.default_resource_limits))
require 'stackprof'
results = StackProf.run(raw: true, out: 'stackprof.dump') do
500_000.times do
@template.render(context)
end
end
Benchmark.ips do |x|
x.report("render") { @template.render(context) }