about summary refs log tree commit homepage
path: root/lib/rainbows/sendfile.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-11-14 02:47:24 +0000
committerEric Wong <e@80x24.org>2015-11-18 02:20:25 +0000
commit70c976bdd85bb8515fea01d6ad6074ef472fc2e0 (patch)
tree51230dc24bb183176b932e0d38e181869b5485e7 /lib/rainbows/sendfile.rb
parent9c9e3949b2ef2f299ff1590d23aa4d053b60a2fd (diff)
downloadrainbows-70c976bdd85bb8515fea01d6ad6074ef472fc2e0.tar.gz
Unicorn 5 removes some constants we were using, and constant
lookups + inline caching are waste of time anyways on newer
Rubies with the opt_str_freeze bytecode instruction.

This may reduce performance for folks on older Rubies (probably
not noticeable); but improves performance for folks on newer
Rubies.
Diffstat (limited to 'lib/rainbows/sendfile.rb')
-rw-r--r--lib/rainbows/sendfile.rb12
1 files changed, 3 insertions, 9 deletions
diff --git a/lib/rainbows/sendfile.rb b/lib/rainbows/sendfile.rb
index 767c0f9..59906e2 100644
--- a/lib/rainbows/sendfile.rb
+++ b/lib/rainbows/sendfile.rb
@@ -52,12 +52,10 @@ class Rainbows::Sendfile < Struct.new(:app)
   # +each+ in case a given concurrency model does not optimize
   # +to_path+ calls.
   class Body < Struct.new(:to_path) # :nodoc: all
-    CONTENT_LENGTH = 'Content-Length'.freeze
-
     def self.new(path, headers)
-      unless headers[CONTENT_LENGTH]
+      unless headers['Content-Length'.freeze]
         stat = File.stat(path)
-        headers[CONTENT_LENGTH] = stat.size.to_s if stat.file?
+        headers['Content-Length'.freeze] = stat.size.to_s if stat.file?
       end
       super(path)
     end
@@ -71,14 +69,10 @@ class Rainbows::Sendfile < Struct.new(:app)
     end
   end
 
-  # :stopdoc:
-  X_SENDFILE = 'X-Sendfile'
-  # :startdoc:
-
   def call(env) # :nodoc:
     status, headers, body = app.call(env)
     headers = Rack::Utils::HeaderHash.new(headers) unless Hash === headers
-    if path = headers.delete(X_SENDFILE)
+    if path = headers.delete('X-Sendfile'.freeze)
       body = Body.new(path, headers) unless body.respond_to?(:to_path)
     end
     [ status, headers, body ]