Changeset 991

Show
Ignore:
Timestamp:
03/06/08 02:41:24 (6 months ago)
Author:
normalperson
Message:

ext/http11: define "HTTP_" with CPP as a constant instead of a Ruby global

This reduces line-wrapping and makes code easier to read as well
as slightly improving performance by avoiding variable/pointer
dereferencing overhead.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ext/http11/http11.c

    r990 r991  
    2222#define id_handler_map rb_intern("@handler_map") 
    2323#define id_http_body rb_intern("@http_body") 
    24  
    25 static VALUE global_http_prefix; 
     24#define HTTP_PREFIX "HTTP_" 
     25#define HTTP_PREFIX_LEN (sizeof(HTTP_PREFIX) - 1) 
     26 
    2627static VALUE global_request_method; 
    2728static VALUE global_request_uri; 
     
    8586   * null-terminated for us. 
    8687   */ 
    87   f = rb_str_new(NULL, RSTRING_LEN(global_http_prefix) + flen); 
    88   memcpy(RSTRING_PTR(f), 
    89          RSTRING_PTR(global_http_prefix), 
    90          RSTRING_LEN(global_http_prefix)); 
    91   memcpy(RSTRING_PTR(f) + RSTRING_LEN(global_http_prefix), field, flen); 
     88  f = rb_str_new(NULL, HTTP_PREFIX_LEN + flen); 
     89  memcpy(RSTRING_PTR(f), HTTP_PREFIX, HTTP_PREFIX_LEN); 
     90  memcpy(RSTRING_PTR(f) + HTTP_PREFIX_LEN, field, flen); 
    9291 
    9392  rb_hash_aset(req, f, v); 
     
    375374  mMongrel = rb_define_module("Mongrel"); 
    376375 
    377   DEF_GLOBAL(http_prefix, "HTTP_"); 
    378376  DEF_GLOBAL(request_method, "REQUEST_METHOD"); 
    379377  DEF_GLOBAL(request_uri, "REQUEST_URI");