From: Joseph Sutton Date: Mon, 7 Mar 2022 23:10:01 +0000 (+1300) Subject: compression: Remove helper variables str1 and str2 X-Git-Tag: talloc-2.3.4~164 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c813ee56377c51bf4be786633b863f85a5f540e;p=thirdparty%2Fsamba.git compression: Remove helper variables str1 and str2 This simplifies the code and makes it clearer. Signed-off-by: Joseph Sutton Reviewed-by: Douglas Bagnall --- diff --git a/lib/compression/lzxpress.c b/lib/compression/lzxpress.c index 7ee2e9e5d56..65feed0aa73 100644 --- a/lib/compression/lzxpress.c +++ b/lib/compression/lzxpress.c @@ -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