ruby-changes:7822
From: xibbar <ko1@a...>
Date: Sun, 14 Sep 2008 22:11:02 +0900 (JST)
Subject: [ruby-changes:7822] Ruby:r19343 (trunk): * lib/cgi/core.rb (CGI::parse): performance improvement
xibbar 2008-09-14 22:10:43 +0900 (Sun, 14 Sep 2008) New Revision: 19343 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19343 Log: * lib/cgi/core.rb (CGI::parse): performance improvement Modified files: trunk/ChangeLog trunk/lib/cgi/core.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 19342) +++ ChangeLog (revision 19343) @@ -1,3 +1,7 @@ +Sun Sep 14 22:09:01 2008 Takeyuki Fujioka <xibbar@r...> + + * lib/cgi/core.rb (CGI::parse): performance improvement + Sun Sep 14 18:33:32 2008 Tadayoshi Funaba <tadf@d...> * complex.c: trivial changes. Index: lib/cgi/core.rb =================================================================== --- lib/cgi/core.rb (revision 19342) +++ lib/cgi/core.rb (revision 19343) @@ -331,17 +331,12 @@ # # "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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/