libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 341b9db92e91d9ddcf8230a0329c52e319bdee1f
parent 95d084fa6ad9dbd7d40d03d1310af1229553c71f
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Sat,  8 Aug 2015 12:29:28 +0000

connection.c: try_ready_chunked_body(): refactoring for optimization and clarity

Diffstat:
Msrc/microhttpd/connection.c | 15+++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -429,7 +429,9 @@ try_ready_chunked_body (struct MHD_Connection *connection) connection->write_buffer = buf; } - if ( (response->data_start <= + if (0 == response->total_size) + ret = 0; /* response must be empty, don't bother calling crc */ + else if ( (response->data_start <= connection->response_write_position) && (response->data_size + response->data_start > connection->response_write_position) ) @@ -446,13 +448,10 @@ try_ready_chunked_body (struct MHD_Connection *connection) else { /* buffer not in range, try to fill it */ - if (0 == response->total_size) - ret = 0; /* response must be empty, don't bother calling crc */ - else - ret = response->crc (response->crc_cls, - connection->response_write_position, - &connection->write_buffer[sizeof (cbuf)], - connection->write_buffer_size - sizeof (cbuf) - 2); + ret = response->crc (response->crc_cls, + connection->response_write_position, + &connection->write_buffer[sizeof (cbuf)], + connection->write_buffer_size - sizeof (cbuf) - 2); } if ( ((ssize_t) MHD_CONTENT_READER_END_WITH_ERROR) == ret) {