-
Notifications
You must be signed in to change notification settings - Fork 1
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
Freeze string literals and mutable constants #128
Conversation
I did this with rubocop: rubocop --only Style/FrozenStringLiteralComment,Style/MutableConstant --auto-correct Opted to not add rubocop at this stage, wanted to limit the amount of work here.
Performance benchmarks? 😉 |
I'm guessing it's hardly noticeable compared to the Addressable/Public-suffix stuff going on under the hood, but if it would be cool to have two more rake tasks, one to measure speed and another to measure allocated objects. Currently I think we're only profiling method calls IIRC. |
I think this should be extracted to a frozen constant as well, if I understand this correctly there will be a new Regex object on each twingly-url/lib/twingly/url.rb Line 208 in 401cbaa
|
Thanks @texpert for showing me this! #128 (comment) Some more reading about this: * https://ruby-doc.org/core-2.4.0/String.html#method-i-2B-40 * https://bugs.ruby-lang.org/issues/11782 * https://rubocop.readthedocs.io/en/latest/cops_performance/#performanceunfreezestring
To avoid creating a new object for every `normalize_blogspot` call. #128 (comment)
I wasn't that serious, but yeah good ideas! :) |
Missed this in 8395155
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.
LGTM
I did this with rubocop:
Opted to not add rubocop at this stage, wanted to limit the amount of
work here.