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

ruby-grape / grape / 24630096760 / 22
97%
master: 97%

Build:
Build:
LAST BUILD BRANCH: perf/build-headers-each-header
DEFAULT BRANCH: master
Ran 19 Apr 2026 01:22PM UTC
Files 153
Run time 6s
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

19 Apr 2026 01:21PM UTC coverage: 62.346% (+0.1%) from 62.203%
24630096760.22

Pull #2686

github

ericproulx
Add Grape::Middleware::PrecomputedContentTypes and short-circuit merge_headers

Grape::Middleware::Base#call does dup.call!(env) per request, so the
+||=+ memoization on content_types / mime_types / content_types_indifferent_access
lived on the per-request dup — it was computed fresh every request.

This change introduces +Grape::Middleware::PrecomputedContentTypes+, an
opt-in mixin that warms the three caches on the parent instance at
initialization time. Per-request dups then inherit the cached values
via +dup+'s ivar copy instead of recomputing +with_indifferent_access+
(~1 µs each).

Grape::Middleware::Error, Formatter, and Versioner::Base include the
module. Plain Grape::Middleware::Base subclasses continue to compute
content_types lazily on first access — no behavior change for custom
middlewares. The module advertises intent at the class declaration,
making the warmup a named capability rather than an initializer side
effect.

Also short-circuits Grape::Middleware::Base#merge_headers when no
headers were set, avoiding both the lazy +Grape::Util::Header.new+
allocation and an empty +merge!+ against the response.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pull Request #2686: Add Grape::Middleware::PrecomputedContentTypes and short-circuit merge_headers

380 of 1156 branches covered (32.87%)

Branch coverage included in aggregate %.

2463 of 3404 relevant lines covered (72.36%)

8.89 hits per line

Source Files on job run-4.0-gemfiles/hashie.gemfile - 24630096760.22
  • Tree
  • List 153
  • Changed 5
  • Source Changed 4
  • Coverage Changed 5
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 24630096760
  • 88d5472c on github
  • Prev Job for on perf/precompute-middleware-caches (#24617960772.17)
  • Next Job for on perf/precompute-middleware-caches (#24630181277.4)
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