/* ===========================================================================
* Function prototypes.
*/
-typedef block_state (*compress_func) (deflate_state *s, int flush);
-/* Compression function. Returns the block state after the call. */
-
static int deflateStateCheck (PREFIX3(stream) *strm);
Z_INTERNAL block_state deflate_stored(deflate_state *s, int flush);
Z_INTERNAL block_state deflate_fast (deflate_state *s, int flush);
/* Maximum stored block length in deflate format (not including header). */
#define MAX_STORED 65535
+/* Compression function. Returns the block state after the call. */
+typedef block_state (*compress_func) (deflate_state *s, int flush);
+/* Match function. Returns the longest match. */
+typedef uint32_t (*match_func) (deflate_state *const s, Pos cur_match);
+
#endif
int bflush; /* set if current block must be flushed */
int64_t dist;
uint32_t match_len;
+ match_func longest_match;
+
+ if (s->max_chain_length <= 1024)
+ longest_match = functable.longest_match;
+ else
+ longest_match = functable.longest_match_slow;
/* Process the input block. */
for (;;) {
* of window index 0 (in particular we have to avoid a match
* of the string with itself at the start of the input file).
*/
- match_len = functable.longest_match_slow(s, hash_head);
+ match_len = longest_match(s, hash_head);
/* longest_match() sets match_start */
if (match_len <= 5 && (s->strategy == Z_FILTERED)) {
Pos limit;
#ifdef LONGEST_MATCH_SLOW
Pos limit_base;
- int32_t rolling_hash;
#else
int32_t early_exit;
#endif
/* Do not waste too much time if we already have a good match */
chain_length = s->max_chain_length;
-#ifdef LONGEST_MATCH_SLOW
- rolling_hash = chain_length > 1024;
-#else
- early_exit = s->level < EARLY_EXIT_TRIGGER_LEVEL;
-#endif
if (best_len >= s->good_match)
chain_length >>= 2;
nice_match = (uint32_t)s->nice_match;
limit = strstart > MAX_DIST(s) ? (Pos)(strstart - MAX_DIST(s)) : 0;
#ifdef LONGEST_MATCH_SLOW
limit_base = limit;
- if (best_len >= STD_MIN_MATCH && rolling_hash) {
+ if (best_len >= STD_MIN_MATCH) {
/* We're continuing search (lazy evaluation). */
uint32_t i, hash;
Pos pos;
mbase_start -= match_offset;
mbase_end -= match_offset;
}
+#else
+ early_exit = s->level < EARLY_EXIT_TRIGGER_LEVEL;
#endif
Assert((unsigned long)strstart <= s->window_size - MIN_LOOKAHEAD, "need lookahead");
for (;;) {
#endif
#ifdef LONGEST_MATCH_SLOW
/* Look for a better string offset */
- if (UNLIKELY(len > STD_MIN_MATCH && match_start + len < strstart && rolling_hash)) {
+ if (UNLIKELY(len > STD_MIN_MATCH && match_start + len < strstart)) {
Pos pos, next_pos;
uint32_t i, hash;
unsigned char *scan_endstr;