From: Mika Lindqvist Date: Sun, 27 Mar 2016 12:02:54 +0000 (+0300) Subject: Merge insert_string and bulk_insert_str. X-Git-Tag: 1.9.9-b1~761 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f111d5cb4219b7d8a4b8776b4392cc64e0efcd07;p=thirdparty%2Fzlib-ng.git Merge insert_string and bulk_insert_str. ** Partial merge of this commit, based on a8c94e9f5a3b9d3c62182bcf84e72304a3c1a6e5 Excludes changes to fill_window_sse.c, changes to fill_window_c() in deflate.c and several unrelated changes in the commit. --- diff --git a/deflate.c b/deflate.c index 556ebaf71..0b392a1e5 100644 --- a/deflate.c +++ b/deflate.c @@ -312,7 +312,7 @@ int ZEXPORT deflateSetDictionary(z_stream *strm, const unsigned char *dictionary while (s->lookahead >= MIN_MATCH) { str = s->strstart; n = s->lookahead - (MIN_MATCH-1); - bulk_insert_str(s, str, n); + insert_string(s, str, n); s->strstart = str + n; s->lookahead = MIN_MATCH-1; fill_window(s); diff --git a/deflate_fast.c b/deflate_fast.c index 59618a37f..c16905375 100644 --- a/deflate_fast.c +++ b/deflate_fast.c @@ -39,7 +39,7 @@ block_state deflate_fast(deflate_state *s, int flush) { */ hash_head = NIL; if (s->lookahead >= MIN_MATCH) { - hash_head = insert_string(s, s->strstart); + hash_head = insert_string(s, s->strstart, 1); } /* Find the longest match, discarding those <= prev_length. @@ -68,7 +68,7 @@ block_state deflate_fast(deflate_state *s, int flush) { s->strstart++; #ifdef NOT_TWEAK_COMPILER do { - insert_string(s, s->strstart); + insert_string(s, s->strstart, 1); s->strstart++; /* strstart never exceeds WSIZE-MAX_MATCH, so there are * always MIN_MATCH bytes ahead. @@ -76,7 +76,7 @@ block_state deflate_fast(deflate_state *s, int flush) { } while (--s->match_length != 0); #else { - bulk_insert_str(s, s->strstart, s->match_length); + insert_string(s, s->strstart, s->match_length); s->strstart += s->match_length; s->match_length = 0; } @@ -86,9 +86,9 @@ block_state deflate_fast(deflate_state *s, int flush) { s->match_length = 0; s->ins_h = s->window[s->strstart]; #ifndef NOT_TWEAK_COMPILER - bulk_insert_str(s, s->strstart + 2 - MIN_MATCH, MIN_MATCH - 2); + insert_string(s, s->strstart + 2 - MIN_MATCH, MIN_MATCH - 2); #else - insert_string(s, s->strstart + 2 - MIN_MATCH); + insert_string(s, s->strstart + 2 - MIN_MATCH, 1); #if MIN_MATCH != 3 #warning Call insert_string() MIN_MATCH-3 more times #endif diff --git a/deflate_medium.c b/deflate_medium.c index c5d39aa44..26a12ebda 100644 --- a/deflate_medium.c +++ b/deflate_medium.c @@ -63,7 +63,7 @@ static void insert_match(deflate_state *s, struct match match) { if (match.match_length) { if (match.strstart >= match.orgstart) { - insert_string(s, match.strstart); + insert_string(s, match.strstart, 1); } } } @@ -93,7 +93,7 @@ static void insert_match(deflate_state *s, struct match match) { #ifdef NOT_TWEAK_COMPILER do { if (likely(match.strstart >= match.orgstart)) { - insert_string(s, match.strstart); + insert_string(s, match.strstart, 1); } match.strstart++; /* strstart never exceeds WSIZE-MAX_MATCH, so there are @@ -113,9 +113,9 @@ static void insert_match(deflate_state *s, struct match match) { s->ins_h = s->window[match.strstart]; if (match.strstart >= 1) #ifndef NOT_TWEAK_COMPILER - bulk_insert_str(s, match.strstart + 2 - MIN_MATCH, MIN_MATCH - 2); + insert_string(s, match.strstart + 2 - MIN_MATCH, MIN_MATCH - 2); #else - insert_string(s, match.strstart + 2 - MIN_MATCH); + insert_string(s, match.strstart + 2 - MIN_MATCH, 1); #if MIN_MATCH != 3 #warning Call insert_string() MIN_MATCH-3 more times #endif @@ -233,7 +233,7 @@ block_state deflate_medium(deflate_state *s, int flush) { } else { hash_head = 0; if (s->lookahead >= MIN_MATCH) { - hash_head = insert_string(s, s->strstart); + hash_head = insert_string(s, s->strstart, 1); } /* set up the initial match to be a 1 byte literal */ @@ -267,7 +267,7 @@ block_state deflate_medium(deflate_state *s, int flush) { /* now, look ahead one */ if (s->lookahead > MIN_LOOKAHEAD) { s->strstart = current_match.strstart + current_match.match_length; - hash_head = insert_string(s, s->strstart); + hash_head = insert_string(s, s->strstart, 1); /* set up the initial match to be a 1 byte literal */ next_match.match_start = 0; diff --git a/deflate_p.h b/deflate_p.h index d5e315cbd..896598055 100644 --- a/deflate_p.h +++ b/deflate_p.h @@ -51,27 +51,14 @@ static inline Pos insert_string_c(deflate_state *const s, const Pos str, uInt co return ret; } -static inline Pos insert_string(deflate_state *const s, const Pos str) { +static inline Pos insert_string(deflate_state *const s, const Pos str, uInt count) { #ifdef X86_SSE4_2_CRC_HASH if (x86_cpu_has_sse42) - return insert_string_sse(s, str, 1); + return insert_string_sse(s, str, count); #endif - return insert_string_c(s, str, 1); + return insert_string_c(s, str, count); } -#ifndef NOT_TWEAK_COMPILER -static inline void bulk_insert_str(deflate_state *const s, Pos startpos, uInt count) { -# ifdef X86_SSE4_2_CRC_HASH - if (x86_cpu_has_sse42) { - insert_string_sse(s, startpos, count); - } else -# endif - { - insert_string_c(s, startpos, count); - } -} -#endif /* NOT_TWEAK_COMPILER */ - /* =========================================================================== * Flush the current block, with given end-of-file flag. * IN assertion: strstart is set to the end of the current match. diff --git a/deflate_slow.c b/deflate_slow.c index 6a855f0c8..f9e81d5ff 100644 --- a/deflate_slow.c +++ b/deflate_slow.c @@ -47,7 +47,7 @@ block_state deflate_slow(deflate_state *s, int flush) { */ hash_head = NIL; if (s->lookahead >= MIN_MATCH) { - hash_head = insert_string(s, s->strstart); + hash_head = insert_string(s, s->strstart, 1); } /* Find the longest match, discarding those <= prev_length. @@ -97,7 +97,7 @@ block_state deflate_slow(deflate_state *s, int flush) { s->prev_length -= 2; do { if (++s->strstart <= max_insert) { - insert_string(s, s->strstart); + insert_string(s, s->strstart, 1); } } while (--s->prev_length != 0); s->match_available = 0; @@ -110,7 +110,7 @@ block_state deflate_slow(deflate_state *s, int flush) { if (unlikely(insert_cnt > max_insert - s->strstart)) insert_cnt = max_insert - s->strstart; - bulk_insert_str(s, s->strstart + 1, insert_cnt); + insert_string(s, s->strstart + 1, insert_cnt); s->prev_length = 0; s->match_available = 0; s->match_length = MIN_MATCH-1;