-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 lookup and lazy object #2002
Conversation
…rating string. It reduced string allocations and lazy_object add a significant performance
Generated by 🚫 danger |
4b9a313
to
dca18e7
Compare
lib/grape/router.rb
Outdated
@@ -160,7 +169,7 @@ def greedy_match?(input) | |||
end | |||
|
|||
def call_with_allow_headers(env, methods, endpoint) | |||
env[Grape::Env::GRAPE_ALLOWED_METHODS] = methods.join(', ') | |||
env[Grape::Env::GRAPE_ALLOWED_METHODS] = -methods.join(', ') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For those who are using ruby >= 2.5
https://rubyreferences.github.io/rubychanges/2.5.html#string--optimized-for-memory-preserving
I guess I could have simply put .freeze
instead of -
. freeze
already does it even in 2.4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! Let's use .freeze
until we change it everywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On it
I merged this. LGTM. |
This optimisation was introduced in ruby-grape#2002. If an api's paths include an ids in the path then this cache can grow in an unbounded manner
This optimisation was introduced in ruby-grape#2002. If an api's paths include an id in the path then this cache can grow in an unbounded manner.
This optimisation was introduced in ruby-grape#2002. If an api's paths include an id in the path then this cache can grow in an unbounded manner.
Hello,
I'm still working on improving string allocations and this PR follows my work.
Here's some stats based on our app:
Overall Grape object allocations (development environment)
benchmark/simple.rb ruby 2.4.9
Thanks