From 689cca132a7da77c80637a938740f40277384fe9 Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Thu, 8 Sep 2005 11:28:54 +0000 Subject: Performance improvements to CGI methods. Closes #1980 git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2151 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 2 ++ .../lib/action_controller/cgi_ext/cgi_methods.rb | 18 +++++++++++------- actionpack/lib/action_controller/cgi_process.rb | 4 ++-- 3 files changed, 15 insertions(+), 9 deletions(-) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index bb721d40dc..b53aceccb5 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Performance improvements to CGI methods. Closes #1980 [Skaes] + * Added :post option to UrlHelper#link_to that makes it possible to do POST requests through normal ahref links using Javascript * Fixed overwrite_params diff --git a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb index d922e48b10..3a14311acf 100755 --- a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb +++ b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb @@ -17,13 +17,17 @@ class CGIMethods #:nodoc: k = CGI.unescape(k) if k v = CGI.unescape(v) if v - keys = split_key(k) - last_key = keys.pop - last_key = keys.pop if (use_array = last_key.empty?) - parent = keys.inject(parsed_params) {|h, k| h[k] ||= {}} - - if use_array then (parent[last_key] ||= []) << v - else parent[last_key] = v + unless k.include?(?[) + parsed_params[k] = v + else + keys = split_key(k) + last_key = keys.pop + last_key = keys.pop if (use_array = last_key.empty?) + parent = keys.inject(parsed_params) {|h, k| h[k] ||= {}} + + if use_array then (parent[last_key] ||= []) << v + else parent[last_key] = v + end end } diff --git a/actionpack/lib/action_controller/cgi_process.rb b/actionpack/lib/action_controller/cgi_process.rb index d1d8a660c7..e9e539cfdc 100644 --- a/actionpack/lib/action_controller/cgi_process.rb +++ b/actionpack/lib/action_controller/cgi_process.rb @@ -125,11 +125,11 @@ module ActionController #:nodoc: private def new_session - CGI::Session.new(@cgi, session_options_with_string_keys.merge("new_session" => true)) + CGI::Session.new(@cgi, session_options_with_string_keys.update("new_session" => true)) end def session_options_with_string_keys - DEFAULT_SESSION_OPTIONS.merge(@session_options).inject({}) { |options, pair| options[pair.first.to_s] = pair.last; options } + DEFAULT_SESSION_OPTIONS.merge(@session_options).inject({}) { |options, (k,v)| options[k.to_s] = v; options } end end -- cgit v1.2.3