Skip to content

Commit

Permalink
Speed up common header reads by avoiding downcase
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information
jeremy authored and josh committed May 15, 2009
1 parent 0ab6b6c commit 0bc5662
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/rack/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,21 +227,23 @@ def to_hash
end

def [](k)
super @names[k.downcase]
super(@names[k] ||= @names[k.downcase])
end

def []=(k, v)
delete k
@names[k.downcase] = k
@names[k] = @names[k.downcase] = k
super k, v
end

def delete(k)
super @names.delete(k.downcase)
canonical = k.downcase
super @names.delete(canonical)
@names.delete_if { |name,| name.downcase == canonical }
end

def include?(k)
@names.has_key? k.downcase
@names.include?(k) || @names.include?(k.downcase)
end

alias_method :has_key?, :include?
Expand Down

0 comments on commit 0bc5662

Please sign in to comment.