From a31af29a22cb22072828391d8f421ccf6c59d9b5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 27 Feb 2010 19:06:10 -0800 Subject: tee_input: do not #dup string buffers It's a waste of memory bandwidth to do memcpy() when we know Unicorn::HttpParser (via rb_str_resize()) will allocate new memory for the string for us. An empty String is "free", as we've already paid the Object cost regardless. --- lib/unicorn/tee_input.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/unicorn/tee_input.rb b/lib/unicorn/tee_input.rb index a7cb4b9..963414b 100644 --- a/lib/unicorn/tee_input.rb +++ b/lib/unicorn/tee_input.rb @@ -21,7 +21,7 @@ module Unicorn super(*args) self.len = parser.content_length self.tmp = len && len < Const::MAX_BODY ? StringIO.new("") : Util.tmpio - self.buf2 = buf.dup + self.buf2 = "" if buf.size > 0 parser.filter_body(buf2, buf) and finalize_input tmp.write(buf2) @@ -82,7 +82,7 @@ module Unicorn end rv else - rv = args.shift || buf2.dup + rv = args.shift || "" diff = tmp.size - tmp.pos if 0 == diff ensure_length(tee(length, rv), length) -- cgit v1.2.3-24-ge0c7