• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ruby-grape / grape / 27917582899 / 28
97%
master: 97%

Build:
DEFAULT BRANCH: master
Ran 21 Jun 2026 09:11PM UTC
Files 166
Run time 4s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

21 Jun 2026 09:10PM UTC coverage: 95.13% (+0.002%) from 95.128%
27917582899.28

push

github

web-flow
Avoid per-entry array allocation in Request#build_headers (#2770)

`build_headers` walked the env with `each_header.with_object(...)`. Because
`Enumerator#with_object` hands the block a single value plus the memo, the
two values `each_header` yields (`k`, `v`) get boxed into a throwaway
`[k, v]` Array on every iteration — which the `|(k, v), headers|` destructure
then immediately unpacks. That is one array allocated, packed, destructured,
and discarded per request header.

Drop `with_object` for a plain `each_header do |k, v|` block writing into a
pre-built `Grape::Util::Header`. `k` and `v` arrive as separate block args
(normal multi-value yield), so no array is boxed, and the accumulator is just
a closed-over local.

Output is byte-identical (`each_header` is `Rack::Request::Env#each_header`,
i.e. full env iteration; the `HTTP_` filter is unchanged). `build_headers`
runs lazily, only when an endpoint reads `headers`.

Measured on a request with ~30 headers: ~43% fewer objects (37 -> 21 per
call) and ~1.36x faster, with the array packing — not the Enumerator object
itself — accounting for the entire gap.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

1101 of 1223 branches covered (90.02%)

Branch coverage included in aggregate %.

3529 of 3644 relevant lines covered (96.84%)

962.83 hits per line

Source Files on job run-4.0-gemfiles/rack_3_0.gemfile - 27917582899.28
  • Tree
  • List 166
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 27917582899
  • 7ac57ff9 on github
  • Prev Job for on master (#27905407970.27)
  • Next Job for on master (#28010180578.10)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc