[core] connection_handle_read_state mark hot case
expect common case to receive completed set of headers
(e.g. from a TLS record or a non-TLS packet containing small header)
@@ -702,7 +702,7 @@ static int connection_handle_read_state(connection * const con) {
if (NULL == c) continue;
clen = buffer_string_length(c->mem) - c->offset;
if (0 == clen) continue;
- if (c->offset > USHRT_MAX) /*(highly unlikely)*/
+ if (__builtin_expect( (c->offset > USHRT_MAX), 0)) /*(highly unlikely)*/
chunkqueue_compact_mem_offset(cq);
hoff[0] = 1; /* number of lines */
@@ -725,8 +725,9 @@ static int connection_handle_read_state(connection * const con) {
return 1;
}
- if (0 != header_len) {
- if (hoff[0] > 1) break; /* common case; request headers complete */
+ if (__builtin_expect( (0 != header_len), 1)) {
+ if (__builtin_expect( (hoff[0] > 1), 1))
+ break; /* common case; request headers complete */
if (discard_blank) { /* skip one blank line e.g. following POST */
if (header_len == clen) continue;
