/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
#ifndef NO_QUICK_STRATEGY
-/* 1 */ {4, 4, 8, 4, deflate_quick},
+/* 1 */ {0, 0, 0, 0, deflate_quick},
/* 2 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */
#else
/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */
/* 2 */ {4, 5, 16, 8, deflate_fast},
#endif
-/* 3 */ {4, 6, 32, 32, deflate_fast},
-
#ifdef NO_MEDIUM_STRATEGY
+/* 3 */ {4, 6, 32, 32, deflate_fast},
/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */
/* 5 */ {8, 16, 32, 32, deflate_slow},
/* 6 */ {8, 16, 128, 128, deflate_slow},
#else
-/* 4 */ {4, 4, 16, 16, deflate_medium}, /* lazy matches */
+/* 3 */ {4, 6, 16, 6, deflate_medium},
+/* 4 */ {4, 12, 32, 24, deflate_medium}, /* lazy matches */
/* 5 */ {8, 16, 32, 32, deflate_medium},
/* 6 */ {8, 16, 128, 128, deflate_medium},
#endif
if (windowBits == 8)
windowBits = 9; /* until 256-byte window bug fixed */
-#if !defined(NO_QUICK_STRATEGY) && !defined(S390_DFLTCC_DEFLATE)
- if (level == 1)
- windowBits = 13;
-#endif
-
s = (deflate_state *) ZALLOC_STATE(strm, 1, sizeof(deflate_state));
if (s == NULL)
return Z_MEM_ERROR;
ALIGNED_(16) struct match current_match;
struct match next_match;
+ /* For levels below 5, don't check the next position for a better match */
+ int early_exit = s->level < 5;
+
memset(¤t_match, 0, sizeof(struct match));
memset(&next_match, 0, sizeof(struct match));
*/
/* If we already have a future match from a previous round, just use that */
- if (next_match.match_length > 0) {
+ if (!early_exit && next_match.match_length > 0) {
current_match = next_match;
next_match.match_length = 0;
} else {
insert_match(s, current_match);
/* now, look ahead one */
- if (LIKELY(s->lookahead > MIN_LOOKAHEAD && (uint32_t)(current_match.strstart + current_match.match_length) < (s->window_size - MIN_LOOKAHEAD))) {
+ if (LIKELY(!early_exit && 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);