Skip to content

Commit cbe0355

Browse files
ericproulxclaude
andcommitted
Avoid array allocation in DSL::Parameters#with
Replace `[@group, opts].compact.reduce(&:deep_merge)` with `@group&.deep_merge(opts) || opts` to avoid allocating a temporary array on every `with` block call. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 166d459 commit cbe0355

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/grape/dsl/parameters.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def optional(*attrs, **opts, &block)
161161
# @param (see #requires)
162162
# @option (see #requires)
163163
def with(**opts, &)
164-
new_group_attrs = [@group, opts].compact.reduce(&:deep_merge)
164+
new_group_attrs = @group&.deep_merge(opts) || opts
165165
new_group_scope(new_group_attrs, &)
166166
end
167167

0 commit comments

Comments
 (0)