-
Notifications
You must be signed in to change notification settings - Fork 266
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
Memoize regexps for common character classes #524
Conversation
1fb1d7e
to
0699e68
Compare
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.
Nice
@dentarg is there any plan to release |
(note that there's a rake task to update the gemspec (I have my instructions for doing a release at https://starkast.wiki/addressable)) |
@ianks 2.8.6 has been released now |
@@ -68,6 +69,18 @@ module NormalizeCharacterClasses | |||
QUERY = %r{[^a-zA-Z0-9\-\.\_\~\!\$\'\(\)\*\+\,\=\:\@\/\?%]|%(?!2B|2b)} | |||
end | |||
|
|||
module CharacterClassesRegexps | |||
AUTHORITY = /[^#{CharacterClasses::AUTHORITY}]/ |
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.
AUTHORITY = /[^#{CharacterClasses::AUTHORITY}]/ | |
AUTHORITY = /[^#{CharacterClasses::AUTHORITY}]/ |
This PR improves the performance of
Addressable::URI#encode
andAddressable::URI#encode_component
by memoizing the default character class regexes instead of recompiling them on every call. This results in the following performance improvements:Addressable::URI#encode_component
Addressable::URI#encode
benchmark