about summary refs log tree commit homepage
path: root/ext
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-08-02 15:38:01 -0700
committerEric Wong <normalperson@yhbt.net>2009-08-09 01:28:28 -0700
commitb512747b3579eac29a59eac7469bb3aa109f78b4 (patch)
treef782728e2fd9947495f1e62ba61290f5048f6b91 /ext
parent6dfc7482e4414a7b2d18af127065c15aede39b62 (diff)
downloadunicorn-b512747b3579eac29a59eac7469bb3aa109f78b4.tar.gz
It's easy enough to just check a single equality without having
extra functions obscuring what's actually going on.
Diffstat (limited to 'ext')
-rw-r--r--ext/unicorn_http/unicorn_http.rl21
1 files 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.");
   }