Skip to content

Commit

Permalink
Merge pull request #795 from eileencodes/reduce-object-allocations
Browse files Browse the repository at this point in the history
Reduce object allocations in Rack::Utils
  • Loading branch information
tenderlove committed Feb 11, 2015
2 parents 2c35243 + c4596b3 commit ec98130
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rack/utils.rb
Expand Up @@ -109,6 +109,7 @@ def parse_query(qs, d = nil, &unescaper)
# ParameterTypeError is raised. Users are encouraged to return a 400 in this
# case.
def parse_nested_query(qs, d = nil)
return {} if qs.empty?
params = KeySpaceConstrainedParams.new

(qs || '').split(d ? /[#{d}] */n : DEFAULT_SEP).each do |p|
Expand Down Expand Up @@ -495,7 +496,7 @@ def [](k)
end

def []=(k, v)
canonical = k.downcase
canonical = k.downcase.freeze
delete k if @names[canonical] && @names[canonical] != k # .delete is expensive, don't invoke it unless necessary
@names[k] = @names[canonical] = k
super k, v
Expand Down

0 comments on commit ec98130

Please sign in to comment.