]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Use UNLIKELY for branches related to rolling hash based on performance profiling.
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Tue, 22 Jun 2021 03:43:51 +0000 (20:43 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Fri, 25 Jun 2021 18:09:14 +0000 (20:09 +0200)
Co-authored-by: Nathan Moinvaziri <nathan@nathanm.com>
deflate.c
match_tpl.h

index 2c0c8499f42b9cba953d5dd150abeb3e2dc9bda1..fa86df0c641b36e5f67e686e4b2edb43d5d04296 100644 (file)
--- 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);
index 6e6665455611d97d9f76575171ba52eac59cdda1..920f715ad07e0f952caf33fc12e11005338aacd2 100644 (file)
@@ -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;