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

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

Build:
Build:
LAST BUILD BRANCH: perf/build-headers-each-header
DEFAULT BRANCH: master
Ran 19 Apr 2026 01:22PM UTC
Files 154
Run time 5s
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: 95.574% (-0.01%) from 95.584%
24630096760.36

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

1044 of 1156 branches covered (90.31%)

Branch coverage included in aggregate %.

3318 of 3408 relevant lines covered (97.36%)

1041.4 hits per line

Source Files on job run-4.0-gemfiles/rails_8_0.gemfile - 24630096760.36
  • Tree
  • List 154
  • Changed 4
  • Source Changed 4
  • Coverage Changed 4
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.20)
  • 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