From: Eric Biggers Date: Sun, 1 Jun 2014 13:31:50 +0000 (-0500) Subject: lzx-compress.c: Clarify there must be at least one optimization pass X-Git-Tag: v1.7.0~67 X-Git-Url: https://wimlib.net/git/?a=commitdiff_plain;h=fade5de00b08590d830a1775b90e3490e78cdca5;p=wimlib lzx-compress.c: Clarify there must be at least one optimization pass --- diff --git a/src/lzx-compress.c b/src/lzx-compress.c index 26a0c0cb..d71c28dd 100644 --- a/src/lzx-compress.c +++ b/src/lzx-compress.c @@ -1303,6 +1303,7 @@ lzx_optimize_block(struct lzx_compressor *ctx, struct lzx_block_spec *spec, unsigned orig_window_pos = spec->window_pos; unsigned orig_cached_pos = ctx->cached_matches_pos; + unsigned num_passes_remaining = num_passes; LZX_ASSERT(ctx->match_window_pos == spec->window_pos); @@ -1314,7 +1315,8 @@ lzx_optimize_block(struct lzx_compressor *ctx, struct lzx_block_spec *spec, /* The first optimal parsing pass is done using the cost model already * set in ctx->costs. Each later pass is done using a cost model * computed from the previous pass. */ - for (unsigned pass = 0; pass < num_passes; pass++) { + do { + --num_passes_remaining; ctx->match_window_pos = orig_window_pos; ctx->cached_matches_pos = orig_cached_pos; @@ -1377,10 +1379,11 @@ lzx_optimize_block(struct lzx_compressor *ctx, struct lzx_block_spec *spec, lzx_make_huffman_codes(&freqs, &spec->codes, ctx->num_main_syms); - if (pass < num_passes - 1) + if (num_passes_remaining) lzx_set_costs(ctx, &spec->codes.lens); ctx->matches_cached = true; - } + } while (num_passes_remaining); + spec->block_type = lzx_choose_verbatim_or_aligned(&freqs, &spec->codes); ctx->matches_cached = false; }