Skip to content

Avoid array allocation in DSL::Parameters#with#2672

Merged
ericproulx merged 1 commit intomasterfrom
ruby_optimizations
Apr 6, 2026
Merged

Avoid array allocation in DSL::Parameters#with#2672
ericproulx merged 1 commit intomasterfrom
ruby_optimizations

Conversation

@ericproulx
Copy link
Copy Markdown
Contributor

@ericproulx ericproulx commented Apr 3, 2026

Summary

  • Replace [@group, opts].compact.reduce(&:deep_merge) with @group&.deep_merge(opts) || opts
  • Avoids allocating a temporary array on every with block call
  • Uses safe navigation operator for a more idiomatic form
  • No behavior change (Hash#deep_merge always returns a Hash)

Test plan

  • bundle exec rspec spec/grape/dsl/parameters_spec.rb — 23 examples, 0 failures

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

Danger Report

No issues found.

View run

@ericproulx ericproulx force-pushed the ruby_optimizations branch 6 times, most recently from b2f64ee to 7e295ef Compare April 5, 2026 22:06
@dblock
Copy link
Copy Markdown
Member

dblock commented Apr 6, 2026

rebase?

@ericproulx ericproulx force-pushed the ruby_optimizations branch from 7e295ef to 7883931 Compare April 6, 2026 20:52
@ericproulx ericproulx merged commit d0c0ea4 into master Apr 6, 2026
79 checks passed
@dblock dblock deleted the ruby_optimizations branch April 7, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants