From b512747b3579eac29a59eac7469bb3aa109f78b4 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 2 Aug 2009 15:38:01 -0700 Subject: http: remove noise functions It's easy enough to just check a single equality without having extra functions obscuring what's actually going on. --- ext/unicorn_http/unicorn_http.rl | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl index 6ce6be4..a9c2243 100644 --- a/ext/unicorn_http/unicorn_http.rl +++ b/ext/unicorn_http/unicorn_http.rl @@ -27,10 +27,6 @@ struct http_parser { static void http_field(VALUE req, const char *field, size_t flen, VALUE val); static void header_done(VALUE req, const char *at, size_t length); -static int http_parser_has_error(struct http_parser *hp); -static int http_parser_is_finished(struct http_parser *hp); - - #define LEN(AT, FPC) (FPC - buffer - hp->AT) #define MARK(M,FPC) (hp->M = (FPC) - buffer) #define PTR_TO(F) (buffer + hp->F) @@ -136,7 +132,7 @@ static void http_parser_execute(struct http_parser *hp, %% write exec; - if (!http_parser_has_error(hp)) + if (hp->cs != http_parser_error) hp->cs = cs; hp->start.offset = p - buffer; @@ -146,16 +142,6 @@ static void http_parser_execute(struct http_parser *hp, assert(hp->field_len <= len && "field has length longer than whole buffer"); } -static int http_parser_has_error(struct http_parser *hp) -{ - return hp->cs == http_parser_error; -} - -static int http_parser_is_finished(struct http_parser *hp) -{ - return hp->cs == http_parser_first_final; -} - static struct http_parser *data_get(VALUE self) { struct http_parser *hp; @@ -164,6 +150,7 @@ static struct http_parser *data_get(VALUE self) assert(hp); return hp; } + static void http_field(VALUE req, const char *field, size_t flen, VALUE val) { VALUE f = find_common_field(field, flen); @@ -302,8 +289,8 @@ static VALUE HttpParser_execute(VALUE self, VALUE req, VALUE data) VALIDATE_MAX_LENGTH(hp->start.offset, HEADER); - if (!http_parser_has_error(hp)) - return http_parser_is_finished(hp) ? Qtrue : Qfalse; + if (hp->cs != http_parser_error) + return hp->cs == http_parser_first_final ? Qtrue : Qfalse; rb_raise(eHttpParserError, "Invalid HTTP format, parsing fails."); } -- cgit v1.2.3-24-ge0c7