return &mf->child_tab[(node << 1) + 1];
}
+/* The minimum permissible value of 'max_len' for bt_matchfinder_get_matches()
+ * and bt_matchfinder_skip_position(). There must be sufficiently many bytes
+ * remaining to load a 32-bit integer from the *next* position. */
+#define BT_MATCHFINDER_REQUIRED_NBYTES 5
+
/* Advance the binary tree matchfinder by one byte, optionally recording
* matches. @record_matches should be a compile-time constant. */
static inline struct lz_match *
* The current position in the input buffer (the position of the sequence
* being matched against).
* @max_len
- * The maximum permissible match length at this position. Must be >= 5.
+ * The maximum permissible match length at this position. Must be >=
+ * BT_MATCHFINDER_REQUIRED_NBYTES.
* @nice_len
* Stop searching if a match of at least this length is found.
* Must be <= @max_len.
if (unlikely(max_len > in_end - in_next)) {
max_len = in_end - in_next;
nice_len = min(max_len, nice_len);
- if (unlikely(max_len < 5)) {
+ if (unlikely(max_len < BT_MATCHFINDER_REQUIRED_NBYTES)) {
in_next++;
cache_ptr->length = 0;
cache_ptr++;
if (unlikely(max_len > in_end - in_next)) {
max_len = in_end - in_next;
nice_len = min(max_len, nice_len);
- if (unlikely(max_len < 5)) {
+ if (unlikely(max_len < BT_MATCHFINDER_REQUIRED_NBYTES)) {
in_next++;
cache_ptr->length = 0;
cache_ptr++;
/* If we've found so many matches that the cache might overflow
* if we keep finding more, then stop finding matches. This
* case is very unlikely. */
- if (unlikely(cache_ptr >= c->cache_overflow_mark || max_len < 5))
+ if (unlikely(cache_ptr >= c->cache_overflow_mark ||
+ max_len < BT_MATCHFINDER_REQUIRED_NBYTES))
break;
matches = cache_ptr;
* highly compressible, so it doesn't matter as much what we do.
*/
if (best_len >= nice_len) {
- if (unlikely(best_len + 5 >= max_len))
+ if (unlikely(best_len +
+ BT_MATCHFINDER_REQUIRED_NBYTES >= max_len))
break;
--best_len;
do {