about summary refs log tree commit homepage
path: root/ext
diff options
context:
space:
mode:
authornormalperson <normalperson@19e92222-5c0b-0410-8929-a290d50e31e9>2008-03-06 07:41:24 +0000
committernormalperson <normalperson@19e92222-5c0b-0410-8929-a290d50e31e9>2008-03-06 07:41:24 +0000
commit2ba9c8518f7cf1195846ca26b2d401e41f4e0cc9 (patch)
tree7d997a9560b76831f6bc25d2ba10c1286c2fd11e /ext
parent094e419ce649632d4cff8be3848f2b8d395cb9ba (diff)
downloadunicorn-2ba9c8518f7cf1195846ca26b2d401e41f4e0cc9.tar.gz
This reduces line-wrapping and makes code easier to read as well
as slightly improving performance by avoiding variable/pointer
dereferencing overhead.


git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@991 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'ext')
-rw-r--r--ext/http11/http11.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/ext/http11/http11.c b/ext/http11/http11.c
index 1e028ee..e7a8658 100644
--- a/ext/http11/http11.c
+++ b/ext/http11/http11.c
@@ -21,8 +21,9 @@ static VALUE eHttpParserError;
 
 #define id_handler_map rb_intern("@handler_map")
 #define id_http_body rb_intern("@http_body")
+#define HTTP_PREFIX "HTTP_"
+#define HTTP_PREFIX_LEN (sizeof(HTTP_PREFIX) - 1)
 
-static VALUE global_http_prefix;
 static VALUE global_request_method;
 static VALUE global_request_uri;
 static VALUE global_fragment;
@@ -84,11 +85,9 @@ void http_field(void *data, const char *field, size_t flen, const char *value, s
    * written twice, and and RSTRING_PTR(f) will already be
    * null-terminated for us.
    */
-  f = rb_str_new(NULL, RSTRING_LEN(global_http_prefix) + flen);
-  memcpy(RSTRING_PTR(f),
-         RSTRING_PTR(global_http_prefix),
-         RSTRING_LEN(global_http_prefix));
-  memcpy(RSTRING_PTR(f) + RSTRING_LEN(global_http_prefix), field, flen);
+  f = rb_str_new(NULL, HTTP_PREFIX_LEN + flen);
+  memcpy(RSTRING_PTR(f), HTTP_PREFIX, HTTP_PREFIX_LEN);
+  memcpy(RSTRING_PTR(f) + HTTP_PREFIX_LEN, field, flen);
 
   rb_hash_aset(req, f, v);
 }
@@ -374,7 +373,6 @@ void Init_http11()
 
   mMongrel = rb_define_module("Mongrel");
 
-  DEF_GLOBAL(http_prefix, "HTTP_");
   DEF_GLOBAL(request_method, "REQUEST_METHOD");
   DEF_GLOBAL(request_uri, "REQUEST_URI");
   DEF_GLOBAL(fragment, "FRAGMENT");