From ece31b975224c3d7025053b2c515a2cbfe6a3061 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Thu, 27 Dec 2018 13:40:40 +1100 Subject: [PATCH] Remove obsolete std/deflate tmp variable --- release/c/wuffs-unsupported-snapshot.c | 18 ++++++++---------- std/deflate/decode_deflate.wuffs | 23 ++++++++++------------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index e26da298..1ecd0f0e 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -6050,7 +6050,6 @@ wuffs_deflate__decoder__init_huff(wuffs_deflate__decoder* self, uint32_t v_key = 0; uint32_t v_value = 0; uint32_t v_cl = 0; - uint32_t v_tmp = 0; uint32_t v_redirect_key = 0; uint32_t v_j = 0; uint32_t v_reversed_key = 0; @@ -6200,10 +6199,9 @@ label_1_break:; v_prev_cl = v_cl; v_key = v_code; if (v_cl > 9) { - v_tmp = (v_cl - 9); - v_cl = v_tmp; - v_redirect_key = ((v_key >> v_tmp) & 511); - v_key = ((v_key)&WUFFS_BASE__LOW_BITS_MASK__U32(v_tmp)); + v_cl -= 9; + v_redirect_key = ((v_key >> v_cl) & 511); + v_key = ((v_key)&WUFFS_BASE__LOW_BITS_MASK__U32(v_cl)); if (v_prev_redirect_key != v_redirect_key) { v_prev_redirect_key = v_redirect_key; v_remaining = (((uint32_t)(1)) << v_cl); @@ -6227,20 +6225,20 @@ label_1_break:; wuffs_deflate__error__internal_error_inconsistent_huffman_decoder_state; goto exit; } - v_tmp = (v_j - 9); - v_initial_high_bits = (((uint32_t)(1)) << v_tmp); + v_j -= 9; + v_initial_high_bits = (((uint32_t)(1)) << v_j); v_top = v_next_top; - if ((v_top + (((uint32_t)(1)) << v_tmp)) > 1234) { + if ((v_top + (((uint32_t)(1)) << v_j)) > 1234) { status = wuffs_deflate__error__internal_error_inconsistent_huffman_decoder_state; goto exit; } - v_next_top = (v_top + (((uint32_t)(1)) << v_tmp)); + v_next_top = (v_top + (((uint32_t)(1)) << v_j)); v_redirect_key = (((uint32_t)(wuffs_deflate__reverse8[(v_redirect_key >> 1)])) | ((v_redirect_key & 1) << 8)); self->private_impl.f_huffs[a_which][v_redirect_key] = - (268435465 | (v_top << 8) | (v_tmp << 4)); + (268435465 | (v_top << 8) | (v_j << 4)); } } if ((v_key >= 512) || (v_counts[v_prev_cl] <= 0)) { diff --git a/std/deflate/decode_deflate.wuffs b/std/deflate/decode_deflate.wuffs index b704463d..8e693791 100644 --- a/std/deflate/decode_deflate.wuffs +++ b/std/deflate/decode_deflate.wuffs @@ -469,9 +469,8 @@ pri func decoder.init_huff!?(which base.u32[..1], n_codes0 base.u32[..320], n_co var key base.u32 var value base.u32 var cl base.u32[..15] - var tmp base.u32[..6] var redirect_key base.u32[..511] - var j base.u32 + var j base.u32[..16] var reversed_key base.u32[..511] var symbol base.u32[..319] var high_bits base.u32 @@ -700,13 +699,11 @@ pri func decoder.init_huff!?(which base.u32[..1], n_codes0 base.u32[..320], n_co key = code if cl > 9 { - // TODO: we shouldn't need a temporary variable. - tmp = cl - 9 - cl = tmp - assert cl <= 9 via "a <= b: a == c; c <= b"(c:tmp) + cl -= 9 + assert cl <= 9 - redirect_key = (key >> tmp) & 511 - key = key.low_bits(n:tmp) + redirect_key = (key >> cl) & 511 + key = key.low_bits(n:cl) if prev_redirect_key != redirect_key { prev_redirect_key = redirect_key @@ -734,17 +731,17 @@ pri func decoder.init_huff!?(which base.u32[..1], n_codes0 base.u32[..320], n_co if (j <= 9) or (15 < j) { return "?internal error: inconsistent Huffman decoder state" } - tmp = j - 9 - initial_high_bits = (1 as base.u32) << tmp + j -= 9 + initial_high_bits = (1 as base.u32) << j top = next_top - if (top + ((1 as base.u32) << tmp)) > 1234 { + if (top + ((1 as base.u32) << j)) > 1234 { return "?internal error: inconsistent Huffman decoder state" } - next_top = top + ((1 as base.u32) << tmp) + next_top = top + ((1 as base.u32) << j) redirect_key = (reverse8[redirect_key >> 1] as base.u32) | ((redirect_key & 1) << 8) - this.huffs[args.which][redirect_key] = 0x10000009 | (top << 8) | (tmp << 4) + this.huffs[args.which][redirect_key] = 0x10000009 | (top << 8) | (j << 4) } } if (key >= (1 << 9)) or (counts[prev_cl] <= 0) {