Skip to content

Commit

Permalink
Remove spurious code
Browse files Browse the repository at this point in the history
The history goes like this:

Commit 0b1ca85 fixed a bug.

Back then we still used the do-while loop thanks to
`request::set_buffer` requiring us to call `request::next` right after
(but only if code was equals to `error_insufficient_data`).

Boost.Http's commit
https://github.com/BoostGSoC14/boost.http/commit/
b573efe21b27b415f45362ca00c3189600799713
changed that. This commit added the following code to the end of
`set_buffer`:

    if (code_ == token::code::error_insufficient_data)
        next();

So we no longer need to manually call `next` after `set_buffer`.

However, this changed the parsing loop condition from:

    priv->parser.code() != http::token::code::end_of_message

to:

    priv->parser.code() != http::token::code::error_insufficient_data
    && priv->parser.code() != http::token::code::end_of_message

Once we moved away from the do-while construct in the parsing loop code,
back in commit 17fbe06, we kept the new
loop condition, even thou now the correct condition would be:

    priv->parser.code() != http::token::code::error_insufficient_data

Less than 48 hours later I realized the mistake and made commit
1d7a943, but kept the spurious
`parser.next()` code.

The extra `parser.next()` wasn't harmful, but it is unneeded code that
will add a cognitive overhead making code harder to understand.

This commit removes this line.
  • Loading branch information
vinipsmaker committed Jul 29, 2018
1 parent 6c8be92 commit ccfc8fd
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/httpserverrequest.cpp
Expand Up @@ -250,7 +250,6 @@ void HttpServerRequest::onReadyRead()

priv->parser.next();
}
priv->parser.next();
priv->buffer.remove(0, priv->parser.parsed_count());

if (is_upgrade) {
Expand Down
1 change: 0 additions & 1 deletion src/websocket.cpp
Expand Up @@ -965,7 +965,6 @@ inline bool WebSocketHttpClient::execute(QByteArray &chunk)

parser.next();
}
parser.next();
chunk.remove(0, parser.parsed_count());

if (ready && headers.contains("Upgrade"))
Expand Down

0 comments on commit ccfc8fd

Please sign in to comment.