From: Douglas Bagnall Date: Sun, 20 Nov 2022 21:23:53 +0000 (+1300) Subject: lib/compression/lzhuff: add debug flag to skip LZ77 X-Git-Tag: talloc-2.4.0~445 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=955214ef6ec0015d8c1e1f8a43cacdf239b4d253;p=thirdparty%2Fsamba.git lib/compression/lzhuff: add debug flag to skip LZ77 Encoding without LZ77 matches is valid, and it is useful for isolating bugs. Signed-off-by: Douglas Bagnall Reviewed-by: Joseph Sutton --- diff --git a/lib/compression/lzxpress_huffman.c b/lib/compression/lzxpress_huffman.c index 7a48ca73425..ef64ea7021f 100644 --- a/lib/compression/lzxpress_huffman.c +++ b/lib/compression/lzxpress_huffman.c @@ -31,6 +31,15 @@ #include "lib/util/byteorder.h" #include "lib/util/bytearray.h" +/* + * DEBUG_NO_LZ77_MATCHES toggles the encoding of matches as matches. If it is + * false the potential match is written as a series of literals, which is a + * valid but usually inefficient encoding. This is useful for isolating a + * problem to either the LZ77 or the Huffman stage. + */ +#ifndef DEBUG_NO_LZ77_MATCHES +#define DEBUG_NO_LZ77_MATCHES false +#endif #define LZXPRESS_ERROR -1LL @@ -574,7 +583,7 @@ static ssize_t lz77_encode_block(struct lzxhuff_compressor_context *cmp_ctx, j = 0; - if (remaining_size < 41) { + if (remaining_size < 41 || DEBUG_NO_LZ77_MATCHES) { /* * There is no point doing a hash table and looking for * matches in this tiny block (remembering we are committed to