about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-09-05 19:33:33 -0700
committerEric Wong <normalperson@yhbt.net>2009-09-07 16:45:43 -0700
commit3547efe6386bb4ad224be49b723d16cde2067f9c (patch)
tree6fcb9d3319d56552e16ccb18c46d1b5e516c2a09
parent9335d300dbf62e7b8bd140f6388358fe71a62bc0 (diff)
It's expensive to create if not needed, and no current released
version of Rack has my proposed optimizations for it yet...
-rw-r--r--ext/clogger_ext/clogger.c2
-rw-r--r--lib/clogger/pure.rb3
2 files changed, 3 insertions, 2 deletions
diff --git a/ext/clogger_ext/clogger.c b/ext/clogger_ext/clogger.c
index 60292f9..b695a5b 100644
--- a/ext/clogger_ext/clogger.c
+++ b/ext/clogger_ext/clogger.c
@@ -682,7 +682,7 @@ static VALUE ccall(struct clogger *c, VALUE env)
                 c->headers = tmp[1];
                 c->body = tmp[2];
 
-                if (cHeaderHash != rb_obj_class(c->headers)) {
+                if (c->need_resp && cHeaderHash != rb_obj_class(c->headers)) {
                         c->headers = rb_funcall(cHeaderHash, new_id, 1, tmp[1]);
                         if (OBJ_FROZEN(rv))
                                 rv = rb_ary_dup(rv);
diff --git a/lib/clogger/pure.rb b/lib/clogger/pure.rb
index 718db9a..2800802 100644
--- a/lib/clogger/pure.rb
+++ b/lib/clogger/pure.rb
@@ -14,6 +14,7 @@ class Clogger
     @fmt_ops = compile_format(opts[:format] || Format::Common, opts)
     @wrap_body = need_wrap_body?(@fmt_ops)
     @reentrant = nil
+    @need_resp = need_response_headers?(@fmt_ops)
     @body_bytes_sent = 0
   end
 
@@ -25,7 +26,7 @@ class Clogger
       raise TypeError, "app response not a 3 element Array: #{resp.inspect}"
     end
     status, headers, body = resp
-    headers = Rack::Utils::HeaderHash.new(headers)
+    headers = Rack::Utils::HeaderHash.new(headers) if @need_resp
     if wrap_body?
       @reentrant = env['rack.multithread']
       @env, @status, @headers, @body = env, status, headers, body