From 2a5c5c522d8c7532e56586b7d4258a3b6b8c68bb Mon Sep 17 00:00:00 2001 From: Joel Drapper Date: Sat, 1 Jul 2023 22:24:57 +0100 Subject: [PATCH] Use `block` instead of `block_given?` for better performance --- lib/phlex/elements.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/phlex/elements.rb b/lib/phlex/elements.rb index e127efdd..3fbec2e3 100644 --- a/lib/phlex/elements.rb +++ b/lib/phlex/elements.rb @@ -42,7 +42,7 @@ def #{method_name}(**attributes, &block) target = @_context.target if attributes.length > 0 # with attributes - if block_given? # with content block + if block # with content block target << "<#{tag}" << (Phlex::ATTRIBUTE_CACHE[respond_to?(:process_attributes) ? (attributes.hash + self.class.hash) : attributes.hash] || __attributes__(**attributes)) << ">" yield_content(&block) target << "" @@ -50,7 +50,7 @@ def #{method_name}(**attributes, &block) target << "<#{tag}" << (Phlex::ATTRIBUTE_CACHE[respond_to?(:process_attributes) ? (attributes.hash + self.class.hash) : attributes.hash] || __attributes__(**attributes)) << ">" end else # without attributes - if block_given? # with content block + if block # with content block target << "<#{tag}>" yield_content(&block) target << ""