From 99911621719a5798e24225ca40a1a11ef856faa5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 12 Aug 2009 16:58:29 -0700 Subject: http: freeze fields when creating them, always Otherwise we'll be creating an extra garbage string because rb_hash_aset can't tell the string isn't being used elsewhere and creates a new frozen one. --- ext/unicorn_http/common_field_optimization.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/unicorn_http/common_field_optimization.h b/ext/unicorn_http/common_field_optimization.h index dd090a6..a714368 100644 --- a/ext/unicorn_http/common_field_optimization.h +++ b/ext/unicorn_http/common_field_optimization.h @@ -104,7 +104,7 @@ static VALUE uncommon_field(const char *field, size_t flen) memcpy(RSTRING_PTR(f), HTTP_PREFIX, HTTP_PREFIX_LEN); memcpy(RSTRING_PTR(f) + HTTP_PREFIX_LEN, field, flen); assert(*(RSTRING_PTR(f) + RSTRING_LEN(f)) == '\0'); /* paranoia */ - return f; + return rb_obj_freeze(f); } #endif /* common_field_optimization_h */ -- cgit v1.2.3-24-ge0c7