From 5facf207004a805d0b0836a6605bb02ab5ac77da Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 23 Apr 2009 21:20:03 -0700 Subject: http_response: minor performance gains Avoid creating garbage every time we lookup the status code along with the message. Also, we can use global const arrays for a little extra performance because we only write one-at-a time Looking at MRI 1.8, Array#join with an empty string argument is slightly better because it skips an append for every iteration. --- lib/unicorn/const.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/unicorn/const.rb') diff --git a/lib/unicorn/const.rb b/lib/unicorn/const.rb index c05d333..c31b8e3 100644 --- a/lib/unicorn/const.rb +++ b/lib/unicorn/const.rb @@ -42,6 +42,9 @@ module Unicorn 503 => 'Service Unavailable', 504 => 'Gateway Time-out', 505 => 'HTTP Version not supported' + }.inject({}) { |hash,(code,msg)| + hash[code] = "#{code} #{msg}" + hash } # Frequently used constants when constructing requests or responses. Many times -- cgit v1.2.3-24-ge0c7