From 5502cddd3554144f3d9988bedce26451713369cb Mon Sep 17 00:00:00 2001 From: Cliff Frey Date: Thu, 27 May 2010 15:04:24 -0700 Subject: [PATCH] reduce http_parser from 60 bytes to 48 bytes This is mostly done by using sized types instead of enums, and reordering fields to allow better packing. I also moved the 'upgrade' field out of the PRIVATE section and into the READ-ONLY section, as I believe that it is supposed to be non-private. --- http_parser.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/http_parser.h b/http_parser.h index de6d66d..1ca3d7a 100644 --- a/http_parser.h +++ b/http_parser.h @@ -94,17 +94,10 @@ enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH }; struct http_parser { /** PRIVATE **/ - enum http_parser_type type; - unsigned short state; - unsigned short header_state; - size_t index; - - /* 1 = Upgrade header was present and the parser has exited because of that. - * 0 = No upgrade header present. - * Should be checked when http_parser_execute() returns in addition to - * error checking. - */ - unsigned short upgrade; + unsigned char type; + unsigned char state; + unsigned char header_state; + unsigned char index; char flags; @@ -122,11 +115,18 @@ struct http_parser { /** READ-ONLY **/ unsigned short status_code; /* responses only */ - enum http_method method; /* requests only */ + unsigned short method; /* requests only */ unsigned short http_major; unsigned short http_minor; char buffer[HTTP_PARSER_MAX_METHOD_LEN]; + /* 1 = Upgrade header was present and the parser has exited because of that. + * 0 = No upgrade header present. + * Should be checked when http_parser_execute() returns in addition to + * error checking. + */ + char upgrade; + /** PUBLIC **/ void *data; /* A pointer to get hook to the "connection" or "socket" object */ };