diff options
author | normalperson <normalperson@19e92222-5c0b-0410-8929-a290d50e31e9> | 2008-03-06 07:41:28 +0000 |
---|---|---|
committer | normalperson <normalperson@19e92222-5c0b-0410-8929-a290d50e31e9> | 2008-03-06 07:41:28 +0000 |
commit | a9ab034e62dbe5740cc1b353aed2320646606c73 (patch) | |
tree | 50a70afcea03447cd436247735b1cbc21a9c3fbb /ext/http11/ext_help.h | |
parent | 2ba9c8518f7cf1195846ca26b2d401e41f4e0cc9 (diff) | |
download | unicorn-a9ab034e62dbe5740cc1b353aed2320646606c73.tar.gz |
Most HTTP traffic will send a small, common subset of headers. For these, we can avoid recreating RString objects and instead use predefined, frozen RString objects. This results in a ~22% speed improvement in header parsing for common cases where clients send the headers we have predefined, frozen objects for. Additionally, new parser tests have been added to ensure the optimizations work (for MRI). There is an optional qsort(3) and bsearch(3) dependency to improve average lookup time for the frozen strings; but it's not enabled due to portability concerns. The linear search performance is acceptable, and can be hand-optimized for the most frequently seen headers by putting those first. git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@992 19e92222-5c0b-0410-8929-a290d50e31e9
Diffstat (limited to 'ext/http11/ext_help.h')
-rw-r--r-- | ext/http11/ext_help.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/ext/http11/ext_help.h b/ext/http11/ext_help.h index 8b4d754..08c0e1e 100644 --- a/ext/http11/ext_help.h +++ b/ext/http11/ext_help.h @@ -4,6 +4,7 @@ #define RAISE_NOT_NULL(T) if(T == NULL) rb_raise(rb_eArgError, "NULL found for " # T " when shouldn't be."); #define DATA_GET(from,type,name) Data_Get_Struct(from,type,name); RAISE_NOT_NULL(name); #define REQUIRE_TYPE(V, T) if(TYPE(V) != T) rb_raise(rb_eTypeError, "Wrong argument type for " # V " required " # T); +#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) #ifdef DEBUG #define TRACE() fprintf(stderr, "> %s:%d:%s\n", __FILE__, __LINE__, __FUNCTION__) |