]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
compression: Remove helper variables str1 and str2
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Mon, 7 Mar 2022 23:10:01 +0000 (12:10 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 12 May 2022 02:22:35 +0000 (02:22 +0000)
This simplifies the code and makes it clearer.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
lib/compression/lzxpress.c

index 7ee2e9e5d5646a8701fbb771b3113f2f3f11be6b..65feed0aa730657e1db4a118f6417c929eaee736 100644 (file)
@@ -62,7 +62,6 @@ ssize_t lzxpress_compress(const uint8_t *uncompressed,
        uint32_t max_offset, best_offset;
        int32_t offset;
        uint32_t max_len, len, best_len, match_len;
-       const uint8_t *str1, *str2;
        uint32_t indic;
        uint32_t indic_pos;
        uint32_t indic_bit, nibble_index;
@@ -91,8 +90,6 @@ ssize_t lzxpress_compress(const uint8_t *uncompressed,
 
                max_offset = uncompressed_pos;
 
-               str1 = &uncompressed[uncompressed_pos];
-
                best_len = 2;
                best_offset = 0;
 
@@ -100,12 +97,13 @@ ssize_t lzxpress_compress(const uint8_t *uncompressed,
 
                /* search for the longest match in the window for the lookahead buffer */
                for (offset = 1; (uint32_t)offset <= max_offset; offset++) {
-                       str2 = &str1[-offset];
-
                        /* maximum len we can encode into metadata */
                        max_len = MIN(0x1FFF, uncompressed_size - uncompressed_pos);
 
-                       for (len = 0; (len < max_len) && (str1[len] == str2[len]); len++);
+                       for (len = 0;
+                            (len < max_len) && (uncompressed[uncompressed_pos + len] ==
+                                                uncompressed[uncompressed_pos + len - offset]);
+                            len++);
 
                        /*
                         * We check if len is better than the value found before, including the