]> wimlib.net Git - wimlib/blobdiff - src/lz_brute_force.c
resource.c: Make extract_chunk_to_fd() static
[wimlib] / src / lz_brute_force.c
index 3d186cc239367e49f86704ac77d339eda029a5c5..548b7887ac6a188642e2f532f151b2647013bd52 100644 (file)
@@ -93,28 +93,35 @@ lz_bf_get_matches(struct lz_mf *mf, struct lz_match matches[])
                goto out;
 
        while (matchptr-- > mf->cur_window) {
-               if (matchptr[best_len] == strptr[best_len] &&
-                   matchptr[best_len - 1] == strptr[best_len - 1] &&
-                   matchptr[0] == strptr[0])
-               {
-                       u32 len = 0;
-
-                       while (++len != max_len)
-                               if (matchptr[len] != strptr[len])
-                                       break;
-
-                       if (len > best_len) {
-                               matches[num_matches++] = (struct lz_match) {
-                                       .len = len,
-                                       .offset = strptr - matchptr,
-                               };
-                               best_len = len;
-                               if (best_len == max_len)
-                                       break;
-                               if (num_matches == mf->params.max_search_depth)
-                                       break;
-                       }
-               }
+
+               u32 len;
+
+               if (matchptr[best_len] != strptr[best_len] ||
+                   matchptr[best_len - 1] != strptr[best_len - 1] ||
+                   matchptr[0] != strptr[0])
+                       goto next_match;
+
+               for (len = 1; len < best_len - 1; len++)
+                       if (matchptr[len] != strptr[len])
+                               goto next_match;
+
+               len = best_len;
+
+               while (++len != max_len)
+                       if (matchptr[len] != strptr[len])
+                               break;
+
+               matches[num_matches++] = (struct lz_match) {
+                       .len = len,
+                       .offset = strptr - matchptr,
+               };
+               best_len = len;
+               if (best_len == max_len)
+                       break;
+               if (num_matches == mf->params.max_search_depth)
+                       break;
+       next_match:
+               ;
        }
 
        /* If the longest match is @nice_match_len in length, it may have been