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

ruby-grape / grape / 24629950730 / 9
97%
master: 97%

Build:
Build:
LAST BUILD BRANCH: perf/build-headers-each-header
DEFAULT BRANCH: master
Ran 19 Apr 2026 01:16PM UTC
Files 152
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:13PM UTC coverage: 95.549% (-0.009%) from 95.558%
24629950730.9

Pull #2686

github

ericproulx
Precompute middleware content-type caches on the parent instance

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:

- Adds a protected +precompute_content_types!+ helper on +Middleware::Base+
  that populates the three ivars 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).
- Has +Middleware::Error+, +Middleware::Formatter+, and
  +Middleware::Versioner::Base+ call it from their +initialize+ (after
  +super+). Versioner::Base additionally warms +available_media_types+.
- Short-circuits +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.

No behavior change. Only middlewares that actually read content_types
opt into the warmup — plain +Middleware::Base+ subclasses still pay
nothing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pull Request #2686: Precompute middleware content-type caches on the parent instance

1045 of 1158 branches covered (90.24%)

Branch coverage included in aggregate %.

3313 of 3403 relevant lines covered (97.36%)

1045.95 hits per line

Source Files on job run-3.3-gemfiles/rack_3_0.gemfile - 24629950730.9
  • Tree
  • List 152
  • Changed 4
  • Source Changed 4
  • Coverage Changed 4
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 24629950730
  • 2ed5613c on github
  • Prev Job for on perf/precompute-middleware-caches (#24617960772.30)
  • Next Job for on perf/precompute-middleware-caches (#24630096760.3)
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