Skip to content

Commit 158f58a

Browse files
committed
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`.
1 parent 333d874 commit 158f58a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/uri/common.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def self.encode_www_form_component(str, enc=nil)
397397
#
398398
# See URI.encode_www_form_component, URI.decode_www_form.
399399
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
400-
raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/ =~ str
400+
raise ArgumentError, "invalid %-encoding (#{str})" if /%(?!\h\h)/.match?(str)
401401
str.b.gsub(/\+|%\h\h/, TBLDECWWWCOMP_).force_encoding(enc)
402402
end
403403

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy