diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-05-10 18:59:43 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-05-10 21:44:25 -0700 |
commit | 1dc79837c336ad8cb4762746acc6a489b8932c81 (patch) | |
tree | a72653b47a31aff5d56ddf2f96b81db0c8d41aea | |
parent | ff3194db3ac25ba8936c06f3815dcbbdb67e04ff (diff) | |
download | unicorn-1dc79837c336ad8cb4762746acc6a489b8932c81.tar.gz |
This reduces garbage generation to improve performance. Rack 1.0 allows InputWrapper to read with an explicit buffer.
-rw-r--r-- | lib/unicorn/app/exec_cgi.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/unicorn/app/exec_cgi.rb b/lib/unicorn/app/exec_cgi.rb index d98b3e4..2c71df9 100644 --- a/lib/unicorn/app/exec_cgi.rb +++ b/lib/unicorn/app/exec_cgi.rb @@ -95,8 +95,9 @@ module Unicorn::App # Allows +out+ to be used as a Rack body. def out.each sysseek(@unicorn_app_exec_cgi_offset) + buf = '' begin - loop { yield(sysread(CHUNK_SIZE)) } + loop { yield(sysread(CHUNK_SIZE, buf)) } rescue EOFError end end @@ -126,7 +127,8 @@ module Unicorn::App tmp.binmode # Rack::Lint::InputWrapper doesn't allow sysread :( - while buf = inp.read(CHUNK_SIZE) + buf = '' + while inp.read(CHUNK_SIZE, buf) tmp.syswrite(buf) end tmp.sysseek(0) |