1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/cgi/core.rb (CGI::parse): performance improvement

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
xibbar 2008-09-14 13:10:43 +00:00
parent 583400c15e
commit 09814e38e1
2 changed files with 7 additions and 8 deletions

View file

@ -331,17 +331,12 @@ class CGI
# # "name2" => ["value1", "value2", ...], ... }
#
def CGI::parse(query)
params = Hash.new([].freeze)
params = {}
query.split(/[&;]/).each do |pairs|
key, value = pairs.split('=',2).collect{|v| CGI::unescape(v) }
if params.has_key?(key)
params[key].push(value)
else
params[key] = [value]
end
params.has_key?(key) ? params[key].push(value) : params[key] = [value]
end
params.default=[].freeze
params
end