diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 4e38e7784..65d856715 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -18,6 +18,10 @@ nav_order: 5 *Alexandre Ignjatovic* +* Reduce UnboundMethod objects by memoizing initialize_parameters + + *Rainer Borene* + * Improve docs about inline templates interpolation. *Hans Lemuet* diff --git a/lib/view_component/base.rb b/lib/view_component/base.rb index 9dd3944af..0bdee95af 100644 --- a/lib/view_component/base.rb +++ b/lib/view_component/base.rb @@ -553,6 +553,7 @@ def identifier # @param parameter [Symbol] The parameter name used when rendering elements of a collection. def with_collection_parameter(parameter) @provided_collection_parameter = parameter + @initialize_parameters = nil end # Strips trailing whitespace from templates before compiling them. @@ -648,7 +649,7 @@ def initialize_parameter_names end def initialize_parameters - instance_method(:initialize).parameters + @initialize_parameters ||= instance_method(:initialize).parameters end def provided_collection_parameter