Skip to content

Commit 5ca8fc0

Browse files
committed
Reduce allocations in Slotable#register_default_slots
1 parent a7be81a commit 5ca8fc0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/view_component/slotable.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ def register_polymorphic_slot(slot_name, types, collection:)
271271
# Called by the compiler, as instance methods are not defined when slots are first registered
272272
def register_default_slots
273273
registered_slots.each do |slot_name, config|
274-
config[:default_method] = instance_methods.find { |method_name| method_name == :"default_#{slot_name}" }
274+
default_method_name = :"default_#{slot_name}"
275+
config[:default_method] = instance_methods.find { |method_name| method_name == default_method_name }
275276

276277
registered_slots[slot_name] = config
277278
end

0 commit comments

Comments
 (0)