Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy join over allow headers #1993

Merged
merged 1 commit into from
Feb 14, 2020

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.
@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