diff options
author | Steven Harman <[email protected]> | 2020-08-18 13:49:08 -0400 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2021-04-22 14:55:44 +0900 |
commit | bbee6968f82137645f2029379906f5b5d3911ead (patch) | |
tree | b0b42775e5e5a2bea223f949b67d8c9c6422cd1e /lib/uri/common.rb | |
parent | 291cfa7125b86d3a14d477effd0e58bdc1723141 (diff) |
[ruby/uri] Use Regexp#match? to avoid extra allocations
`#=~` builds `MatchData`, requiring extra allocations as compared to
`#match?`, which returns a boolean w/o having to build the `MatchData`.
https://github.com/ruby/uri/commit/158f58a9cc
Diffstat (limited to 'lib/uri/common.rb')
-rw-r--r-- | lib/uri/common.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/uri/common.rb b/lib/uri/common.rb index d818592b74..915c0e9519 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -321,7 +321,7 @@ module URI # # See URI.encode_www_form_component, URI.decode_www_form. def self.decode_www_form_component(str, enc=Encoding::UTF_8) - raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/ =~ str + raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str) str.b.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc) end |