*/
if (s->lookahead < MIN_LOOKAHEAD) {
fill_window(s);
- if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
+ if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH)) {
return need_more;
}
- if (s->lookahead == 0)
+ if (UNLIKELY(s->lookahead == 0))
break; /* flush the current block */
}
s->lookahead--;
s->strstart++;
}
- if (bflush)
+ if (UNLIKELY(bflush))
FLUSH_BLOCK(s, 0);
}
s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
- if (flush == Z_FINISH) {
+ if (UNLIKELY(flush == Z_FINISH)) {
FLUSH_BLOCK(s, 1);
return finish_done;
}
- if (s->sym_next)
+ if (UNLIKELY(s->sym_next))
FLUSH_BLOCK(s, 0);
return block_done;
}
return;
/* matches that are not long enough we need to emit as literals */
- if (match.match_length < MIN_MATCH) {
+ if (LIKELY(match.match_length < MIN_MATCH)) {
match.strstart++;
match.match_length--;
- if (match.match_length > 0) {
+ if (UNLIKELY(match.match_length > 0)) {
if (match.strstart >= match.orgstart) {
if (match.strstart + match.match_length - 1 >= match.orgstart) {
functable.insert_string(s, match.strstart, match.match_length);
orig = s->window + n.strstart - 1;
while (*match == *orig) {
- if (c.match_length < 1)
+ if (UNLIKELY(c.match_length < 1))
break;
- if (n.strstart <= limit)
+ if (UNLIKELY(n.strstart <= limit))
break;
- if (n.match_length >= 256)
+ if (UNLIKELY(n.match_length >= 256))
break;
- if (n.match_start <= 1)
+ if (UNLIKELY(n.match_start <= 1))
break;
n.strstart--;
if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
return need_more;
}
- if (s->lookahead == 0)
+ if (UNLIKELY(s->lookahead == 0))
break; /* flush the current block */
next_match.match_length = 0;
}
*/
current_match.match_length = functable.longest_match(s, hash_head);
current_match.match_start = s->match_start;
- if (current_match.match_length < MIN_MATCH)
+ if (UNLIKELY(current_match.match_length < MIN_MATCH))
current_match.match_length = 1;
- if (current_match.match_start >= current_match.strstart) {
+ if (UNLIKELY(current_match.match_start >= current_match.strstart)) {
/* this can happen due to some restarts */
current_match.match_length = 1;
}
insert_match(s, current_match);
/* now, look ahead one */
- if (s->lookahead > MIN_LOOKAHEAD && (uint32_t)(current_match.strstart + current_match.match_length) < (s->window_size - MIN_LOOKAHEAD)) {
+ if (LIKELY(s->lookahead > MIN_LOOKAHEAD && (uint32_t)(current_match.strstart + current_match.match_length) < (s->window_size - MIN_LOOKAHEAD))) {
s->strstart = current_match.strstart + current_match.match_length;
hash_head = functable.quick_insert_string(s, s->strstart);
*/
next_match.match_length = functable.longest_match(s, hash_head);
next_match.match_start = s->match_start;
- if (next_match.match_start >= next_match.strstart) {
+ if (UNLIKELY(next_match.match_start >= next_match.strstart)) {
/* this can happen due to some restarts */
next_match.match_length = 1;
}
/* move the "cursor" forward */
s->strstart += current_match.match_length;
- if (bflush)
+ if (UNLIKELY(bflush))
FLUSH_BLOCK(s, 0);
}
s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
FLUSH_BLOCK(s, 1);
return finish_done;
}
- if (s->sym_next)
+ if (UNLIKELY(s->sym_next))
FLUSH_BLOCK(s, 0);
return block_done;
last = (flush == Z_FINISH) ? 1 : 0;
- if (last && s->block_open != 2) {
+ if (UNLIKELY(last && s->block_open != 2)) {
/* Emit end of previous block */
QUICK_END_BLOCK(s, 0);
/* Emit start of last block */
QUICK_START_BLOCK(s, last);
- } else if (s->block_open == 0 && s->lookahead > 0) {
+ } else if (UNLIKELY(s->block_open == 0 && s->lookahead > 0)) {
/* Start new block only when we have lookahead data, so that if no
input data is given an empty block will not be written */
QUICK_START_BLOCK(s, last);
}
do {
- if (s->pending + ((BIT_BUF_SIZE + 7) >> 3) >= s->pending_buf_size) {
+ if (UNLIKELY(s->pending + ((BIT_BUF_SIZE + 7) >> 3) >= s->pending_buf_size)) {
flush_pending(s->strm);
if (s->strm->avail_out == 0 && flush != Z_FINISH) {
return need_more;
}
}
- if (s->lookahead < MIN_LOOKAHEAD) {
+ if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD)) {
fill_window(s);
- if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
+ if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH)) {
return need_more;
}
- if (s->lookahead == 0)
+ if (UNLIKELY(s->lookahead == 0))
break;
- if (s->block_open == 0) {
+ if (UNLIKELY(s->block_open == 0)) {
/* Start new block when we have lookahead data, so that if no
input data is given an empty block will not be written */
QUICK_START_BLOCK(s, last);
}
}
- if (s->lookahead >= MIN_MATCH) {
+ if (LIKELY(s->lookahead >= MIN_MATCH)) {
hash_head = functable.quick_insert_string(s, s->strstart);
dist = s->strstart - hash_head;
match_len = functable.compare258(s->window + s->strstart, s->window + hash_head);
if (match_len >= MIN_MATCH) {
- if (match_len > s->lookahead)
+ if (UNLIKELY(match_len > s->lookahead))
match_len = s->lookahead;
check_match(s, s->strstart, hash_head, match_len);
s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
- if (last) {
+ if (UNLIKELY(last)) {
if (s->strm->avail_out == 0)
return s->strm->avail_in == 0 ? finish_started : need_more;
*/
if (s->lookahead < MIN_LOOKAHEAD) {
fill_window(s);
- if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
+ if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH)) {
return need_more;
}
- if (s->lookahead == 0)
+ if (UNLIKELY(s->lookahead == 0))
break; /* flush the current block */
}
* dictionary, and set hash_head to the head of the hash chain:
*/
hash_head = NIL;
- if (s->lookahead >= MIN_MATCH) {
+ if (LIKELY(s->lookahead >= MIN_MATCH)) {
hash_head = functable.quick_insert_string(s, s->strstart);
}
s->match_available = 0;
s->strstart += mov_fwd + 1;
- if (bflush)
+ if (UNLIKELY(bflush))
FLUSH_BLOCK(s, 0);
} else if (s->match_available) {
* is longer, truncate the previous match to a single literal.
*/
bflush = zng_tr_tally_lit(s, s->window[s->strstart-1]);
- if (bflush)
+ if (UNLIKELY(bflush))
FLUSH_BLOCK_ONLY(s, 0);
s->prev_length = match_len;
s->strstart++;
s->lookahead--;
- if (s->strm->avail_out == 0)
+ if (UNLIKELY(s->strm->avail_out == 0))
return need_more;
} else {
/* There is no previous match to compare with, wait for
}
}
Assert(flush != Z_NO_FLUSH, "no flush?");
- if (s->match_available) {
+ if (UNLIKELY(s->match_available)) {
(void) zng_tr_tally_lit(s, s->window[s->strstart-1]);
s->match_available = 0;
}
s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
- if (flush == Z_FINISH) {
+ if (UNLIKELY(flush == Z_FINISH)) {
FLUSH_BLOCK(s, 1);
return finish_done;
}
- if (s->sym_next)
+ if (UNLIKELY(s->sym_next))
FLUSH_BLOCK(s, 0);
return block_done;
}