about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-09-04 19:26:42 -0700
committerEric Wong <normalperson@yhbt.net>2009-09-04 19:26:42 -0700
commit1d764d806b65d392fdb3f3dd8055ed18d42a5c2b (patch)
tree86810d8b724de1d8b7241eff719ef4f5dd819661
parent09cae70d5509530ed3abff9046b1dc0fe448b3b3 (diff)
Otherwise modify the response array in place since
most frameworks give you a modifiable array for you
to play with anyways.
-rw-r--r--ext/clogger_ext/clogger.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/ext/clogger_ext/clogger.c b/ext/clogger_ext/clogger.c
index bec4c08..ae5e1bb 100644
--- a/ext/clogger_ext/clogger.c
+++ b/ext/clogger_ext/clogger.c
@@ -684,7 +684,8 @@ static VALUE ccall(struct clogger *c, VALUE env)
 
                 if (cHeaderHash != rb_obj_class(c->headers)) {
                         c->headers = rb_funcall(cHeaderHash, new_id, 1, tmp[1]);
-                        rv = rb_ary_dup(rv);
+                        if (OBJ_FROZEN(rv))
+                                rv = rb_ary_dup(rv);
                         rb_ary_store(rv, 1, c->headers);
                 }
         } else {
@@ -712,10 +713,8 @@ static VALUE clogger_call(VALUE self, VALUE env)
         VALUE rv;
 
         if (c->wrap_body) {
-                VALUE tmp;
-
                 if (c->reentrant < 0) {
-                        tmp = rb_hash_aref(env, g_rack_multithread);
+                        VALUE tmp = rb_hash_aref(env, g_rack_multithread);
                         c->reentrant = Qfalse == tmp ? 0 : 1;
                 }
                 if (c->reentrant) {
@@ -724,10 +723,11 @@ static VALUE clogger_call(VALUE self, VALUE env)
                 }
 
                 rv = ccall(c, env);
-                tmp = rb_ary_dup(rv);
-                rb_ary_store(tmp, 2, self);
+                if (OBJ_FROZEN(rv))
+                        rv = rb_ary_dup(rv);
+                rb_ary_store(rv, 2, self);
 
-                return tmp;
+                return rv;
         }
 
         rv = ccall(c, env);