summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-02-27 19:06:10 -0800
committerEric Wong <normalperson@yhbt.net>2010-02-27 19:13:24 -0800
commita31af29a22cb22072828391d8f421ccf6c59d9b5 (patch)
tree51033b6bc13a3f73b985bd61e3ab7d608e359b2a
parenta5f4d11cdb9465b1ffa2892b3d84ee53b8962930 (diff)
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.
-rw-r--r--lib/unicorn/tee_input.rb4
1 files 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)