diff options
author | xibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-14 13:10:43 +0000 |
---|---|---|
committer | xibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-14 13:10:43 +0000 |
commit | 09814e38e1933d470c781d73e1d2178103f7523d (patch) | |
tree | 529ede656956a58fb8efbf987529d577a19e5235 | |
parent | 583400c15eb3bf88fb2e2f9eb62c44608297ba20 (diff) |
* 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
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | lib/cgi/core.rb | 11 |
2 files changed, 7 insertions, 8 deletions
@@ -1,3 +1,7 @@ +Sun Sep 14 22:09:01 2008 Takeyuki Fujioka <[email protected]> + + * lib/cgi/core.rb (CGI::parse): performance improvement + Sun Sep 14 18:33:32 2008 Tadayoshi Funaba <[email protected]> * complex.c: trivial changes. diff --git a/lib/cgi/core.rb b/lib/cgi/core.rb index e5424f5e34..16b25c5734 100644 --- a/lib/cgi/core.rb +++ b/lib/cgi/core.rb @@ -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 |