From 21e1fd3f5c53ea3833d54c18e1a4b92e710e1189 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 6 Sep 2009 14:29:52 -0700 Subject: http: remove needless goto There's no need to use a goto here to avoid one level of nesting. --- ext/unicorn_http/unicorn_http.rl | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'ext') diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl index 99f0ff6..f8649fe 100644 --- a/ext/unicorn_http/unicorn_http.rl +++ b/ext/unicorn_http/unicorn_http.rl @@ -619,22 +619,21 @@ static VALUE HttpParser_filter_body(VALUE self, VALUE buf, VALUE data) OBJ_TAINT(buf); /* keep weirdo $SAFE users happy */ if (HP_FL_TEST(hp, CHUNKED)) { - if (chunked_eof(hp)) - goto end_of_body; - - hp->s.dest_offset = 0; - http_parser_execute(hp, buf, dptr, dlen); - if (hp->cs == http_parser_error) - rb_raise(eHttpParserError, "Invalid HTTP format, parsing fails."); - - assert(hp->s.dest_offset <= hp->start.offset); - advance_str(data, hp->start.offset); - rb_str_set_len(buf, hp->s.dest_offset); - - if (RSTRING_LEN(buf) == 0 && chunked_eof(hp)) { - assert(hp->len.chunk == 0); - } else { - data = Qnil; + if (!chunked_eof(hp)) { + hp->s.dest_offset = 0; + http_parser_execute(hp, buf, dptr, dlen); + if (hp->cs == http_parser_error) + rb_raise(eHttpParserError, "Invalid HTTP format, parsing fails."); + + assert(hp->s.dest_offset <= hp->start.offset); + advance_str(data, hp->start.offset); + rb_str_set_len(buf, hp->s.dest_offset); + + if (RSTRING_LEN(buf) == 0 && chunked_eof(hp)) { + assert(hp->len.chunk == 0); + } else { + data = Qnil; + } } } else { /* no need to enter the Ragel machine for unchunked transfers */ @@ -651,7 +650,6 @@ static VALUE HttpParser_filter_body(VALUE self, VALUE buf, VALUE data) data = Qnil; } } -end_of_body: hp->start.offset = 0; /* for trailer parsing */ return data; } -- cgit v1.2.3-24-ge0c7