-
-
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
Regex string allocation #1943
Regex string allocation #1943
Conversation
Generated by 🚫 danger |
CHANGELOG.md
Outdated
@@ -3,6 +3,7 @@ | |||
#### Features | |||
|
|||
* Your contribution here. | |||
* [#1943](https://github.com/ruby-grape/grape/pull/1943): Regex string allocation - [@ericproulx](https://github.com/ericproulx). |
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.
Nitpick, this should describe what it does, eg. "Reduce number of regex string allocations"
Great work. Rebase, I'll merge. |
a1a3a03
to
85346f2
Compare
…string allocation. Changelog
85346f2
to
489e900
Compare
CHANGELOG.md
Outdated
@@ -3,7 +3,8 @@ | |||
#### Features | |||
|
|||
* Your contribution here. | |||
* [#1942](https://github.com/ruby-grape/grape/pull/1942): Optimized retained memory methods - [@ericproulx](https://github.com/ericproulx). | |||
* [#1943](https://github.com/ruby-grape/grape/pull/1943): Reduce number of regex string allocations - [@ericproulx](https://github.com/ericproulx). | |||
[#1942](https://github.com/ruby-grape/grape/pull/1942): Optimized retained memory methods - [@ericproulx](https://github.com/ericproulx). |
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.
Missing *
so danger complains.
Merged thank you |
Use Regexp instead of // for regex in router.rb for a more efficient string allocation.
While memory profilling our app, I found these strange memory allocations :
Turns out, its 2 regex defined in router.rb with interpolation. I replaced the 2 lliteral regexs by the Regexp constructor. Therefore, the strings above (memory profiling) are just allocated once and benefits from the frozen_string_literal