]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
xz: Remove unused code and simplify
authorLasse Collin <lasse.collin@tukaani.org>
Fri, 10 May 2024 17:33:08 +0000 (20:33 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Mon, 13 May 2024 12:31:15 +0000 (15:31 +0300)
opt_mode == MODE_COMPRESS isn't possible when HAVE_ENCODERS isn't
defined. Thus, when *encoding*, the message about *decoder* memory
usage is possible to show only when both encoder and decoder have
been built.

Since the message is shown only at V_DEBUG, skip the memusage
calculation if verbosity level isn't high enough.

Fixes: 5f0c5a04388f8334962c70bc37a8c2ff8f605e0a
src/xz/coder.c

index 84eedd0ebfbdb44ea7736dd441669116ca1646a9..1e84f58dd7a0144114c169d1788043106ed65a0c 100644 (file)
@@ -532,18 +532,10 @@ coder_set_compression_settings(void)
        // NOTE: If only encoder support was built, we cannot show the
        // what the decoder memory usage will be.
        message_mem_needed(V_DEBUG, memory_usage);
-#ifdef HAVE_DECODERS
-       if (opt_mode == MODE_COMPRESS) {
-#ifdef HAVE_ENCODERS
-               const uint64_t decmem =
-                               filters_memusage_max(NULL, false);
-#else
-               // If encoders are not enabled, then --block-list is never
-               // usable and the filter chains 1-9 are never used.
-               // So there is no need to find the maximum decoder memory
-               // required in this case.
-               const uint64_t decmem = lzma_raw_decoder_memusage(filters[0]);
-#endif
+
+#if defined(HAVE_ENCODERS) && defined(HAVE_DECODERS)
+       if (opt_mode == MODE_COMPRESS && message_verbosity_get() >= V_DEBUG) {
+               const uint64_t decmem = filters_memusage_max(NULL, false);
                if (decmem != UINT64_MAX)
                        message(V_DEBUG, _("Decompression will need "
                                        "%s MiB of memory."), uint64_to_str(