Skip to content

Conversation

@ericproulx
Copy link
Contributor

Hi,

While profiling my app, I found this :

266 "GET, HEAD"
266 /Users/eproulx/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/grape1.3.0/lib/grape/api/instance.rb:230

60  "POST"
60  /Users/eproulx/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/grape1.3.0/lib/grape/api/instance.rb:230

30  "PATCH"
30  /Users/eproulx/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/grape1.3.0/lib/grape/api/instance.rb:230

22  "GET, POST, HEAD"
22  /Users/eproulx/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/grape1.3.0/lib/grape/api/instance.rb:230

20  "GET, PATCH, HEAD"
20  /Users/eproulx/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/grape1.3.0/lib/grape/api/instance.rb:230

I figured that joining allowed headers while not actually requesting OPTIONS is a small waste of memory. Instead, we could join them only when needed.

I also replaced string literal 'OPTIONS' by the Http::Headers::OPTIONS

Thanks

@grape-bot
Copy link

grape-bot commented Feb 14, 2020

1 Warning
⚠️ There’re library changes, but not tests. That’s OK as long as you’re refactoring existing code.

Generated by 🚫 danger

…ault it's joined when called

Replaced 'OPTIONS' by actual Grape::Http::Headers::OPTIONS.
@ericproulx ericproulx force-pushed the lazy_join_allow_header branch from 29bad9b to 2d5a6a8 Compare February 14, 2020 10:31
@dblock dblock merged commit bfb4da5 into ruby-grape:master Feb 14, 2020
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.

3 participants