Permalink
Browse files

Performance improvements to CGI methods. Closes #1980

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2151 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 7b235f0 commit 689cca132a7da77c80637a938740f40277384fe9 @seckar seckar committed Sep 8, 2005
View
@@ -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
@@ -17,13 +17,17 @@ def CGIMethods.parse_query_parameters(query_string)
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
}
@@ -125,11 +125,11 @@ def method_missing(method_id, *arguments)
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

0 comments on commit 689cca1

Please sign in to comment.