From: Hans Kristian Rosbach Date: Tue, 22 Jun 2021 03:43:51 +0000 (-0700) Subject: Use UNLIKELY for branches related to rolling hash based on performance profiling. X-Git-Tag: 2.1.0-beta1~544 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8916f295e00a942d184a750730740251e9c6aaa7;p=thirdparty%2Fzlib-ng.git Use UNLIKELY for branches related to rolling hash based on performance profiling. Co-authored-by: Nathan Moinvaziri --- diff --git a/deflate.c b/deflate.c index 2c0c8499f..fa86df0c6 100644 --- a/deflate.c +++ b/deflate.c @@ -1250,7 +1250,7 @@ void Z_INTERNAL fill_window(deflate_state *s) { /* Initialize the hash value now that we have some input: */ if (s->lookahead + s->insert >= STD_MIN_MATCH) { unsigned int str = s->strstart - s->insert; - if (s->max_chain_length > 1024) { + if (UNLIKELY(s->max_chain_length > 1024)) { s->ins_h = s->update_hash(s, s->window[str], s->window[str+1]); } else if (str >= 1) { s->quick_insert_string(s, str + 2 - STD_MIN_MATCH); diff --git a/match_tpl.h b/match_tpl.h index 6e6665455..920f715ad 100644 --- a/match_tpl.h +++ b/match_tpl.h @@ -217,7 +217,7 @@ Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) { #endif #ifdef LONGEST_MATCH_SLOW /* Look for a better string offset */ - if (len > STD_MIN_MATCH && match_start + len < strstart && rolling_hash) { + if (UNLIKELY(len > STD_MIN_MATCH && match_start + len < strstart && rolling_hash)) { Pos pos, next_pos; uint32_t i, hash; unsigned char *scan_endstr;