Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce allocations in turbo_stream_action_tag (#415)
This commit eliminates a few unnecessary allocations in `turbo_stream_action_tag`: **Benchmark** ```ruby # frozen_string_literal: true require "benchmark/memory" class Helpers include Turbo::Streams::ActionHelper end class Message include ActiveModel::API def to_key() = [1] end helpers = Helpers.new message = Message.new Benchmark.memory do |x| helpers.turbo_stream_action_tag("remove", target: message) # warmup x.report("turbo_stream_action_tag") do helpers.turbo_stream_action_tag("remove", target: message) end end ``` **Before** ``` Calculating ------------------------------------- turbo_stream_action_tag 2.554k memsize ( 0.000 retained) 35.000 objects ( 0.000 retained) 12.000 strings ( 0.000 retained) ``` **After** ``` Calculating ------------------------------------- turbo_stream_action_tag 2.138k memsize ( 0.000 retained) 31.000 objects ( 0.000 retained) 12.000 strings ( 0.000 retained) ```
- Loading branch information