From 1d764d806b65d392fdb3f3dd8055ed18d42a5c2b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 4 Sep 2009 19:26:42 -0700 Subject: ext: only duplicate frozen response arrays Otherwise modify the response array in place since most frameworks give you a modifiable array for you to play with anyways. --- ext/clogger_ext/clogger.c | 14 +++++++------- 1 file 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); -- cgit v1.2.3-24-ge0c7