diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 4b51d834..fdfea411 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -27334,9 +27334,8 @@ wuffs_deflate__decoder__decode_huffman_bmi2( status = wuffs_base__make_status(wuffs_deflate__error__bad_distance); goto exit; } - v_hdist = (self->private_impl.f_history_index - v_hdist); wuffs_base__io_writer__limited_copy_u32_from_slice( - &iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), (v_hdist & 32767))); + &iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), ((self->private_impl.f_history_index - v_hdist) & 32767))); if (v_length == 0) { goto label__loop__continue; } @@ -27600,9 +27599,8 @@ wuffs_deflate__decoder__decode_huffman_fast32( status = wuffs_base__make_status(wuffs_deflate__error__bad_distance); goto exit; } - v_hdist = (self->private_impl.f_history_index - v_hdist); wuffs_base__io_writer__limited_copy_u32_from_slice( - &iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), (v_hdist & 32767))); + &iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), ((self->private_impl.f_history_index - v_hdist) & 32767))); if (v_length == 0) { goto label__loop__continue; } @@ -27813,9 +27811,8 @@ wuffs_deflate__decoder__decode_huffman_fast64__choosy_default( status = wuffs_base__make_status(wuffs_deflate__error__bad_distance); goto exit; } - v_hdist = (self->private_impl.f_history_index - v_hdist); wuffs_base__io_writer__limited_copy_u32_from_slice( - &iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), (v_hdist & 32767))); + &iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), ((self->private_impl.f_history_index - v_hdist) & 32767))); if (v_length == 0) { goto label__loop__continue; } @@ -28146,9 +28143,8 @@ wuffs_deflate__decoder__decode_huffman_slow( status = wuffs_base__make_status(wuffs_deflate__error__bad_distance); goto exit; } - v_hdist = (self->private_impl.f_history_index - v_hdist); v_n_copied = wuffs_base__io_writer__limited_copy_u32_from_slice( - &iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), (v_hdist & 32767))); + &iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), ((self->private_impl.f_history_index - v_hdist) & 32767))); if (v_n_copied < v_hlen) { v_length -= v_n_copied; status = wuffs_base__make_status(wuffs_base__suspension__short_write); diff --git a/std/deflate/decode_huffman_bmi2.wuffs b/std/deflate/decode_huffman_bmi2.wuffs index d3ce5dc2..3389e94d 100644 --- a/std/deflate/decode_huffman_bmi2.wuffs +++ b/std/deflate/decode_huffman_bmi2.wuffs @@ -219,18 +219,14 @@ pri func decoder.decode_huffman_bmi2!(dst: base.io_writer, src: base.io_reader) if this.history_index < hdist { return "#bad distance" } - // Re-purpose the hdist variable as the this.history index to - // start copying from. - hdist = this.history_index - hdist - // Copy from hdist to the end of this.history. + // Copy from this.history[(this.history_index - hdist) ..]. // // This copying is simpler than the decode_huffman_slow version // because it cannot yield. We have already checked that // args.dst.length() is large enough. args.dst.limited_copy_u32_from_slice!( - up_to: hlen, s: this.history[hdist & 0x7FFF ..]) - + up_to: hlen, s: this.history[(this.history_index - hdist) & 0x7FFF ..]) if length == 0 { // No need to copy from args.dst. continue.loop diff --git a/std/deflate/decode_huffman_fast32.wuffs b/std/deflate/decode_huffman_fast32.wuffs index 27523141..3ab0c2a8 100644 --- a/std/deflate/decode_huffman_fast32.wuffs +++ b/std/deflate/decode_huffman_fast32.wuffs @@ -324,18 +324,14 @@ pri func decoder.decode_huffman_fast32!(dst: base.io_writer, src: base.io_reader if this.history_index < hdist { return "#bad distance" } - // Re-purpose the hdist variable as the this.history index to - // start copying from. - hdist = this.history_index - hdist - // Copy from hdist to the end of this.history. + // Copy from this.history[(this.history_index - hdist) ..]. // // This copying is simpler than the decode_huffman_slow version // because it cannot yield. We have already checked that // args.dst.length() is large enough. args.dst.limited_copy_u32_from_slice!( - up_to: hlen, s: this.history[hdist & 0x7FFF ..]) - + up_to: hlen, s: this.history[(this.history_index - hdist) & 0x7FFF ..]) if length == 0 { // No need to copy from args.dst. continue.loop diff --git a/std/deflate/decode_huffman_fast64.wuffs b/std/deflate/decode_huffman_fast64.wuffs index 0a8cc8a3..2030b51a 100644 --- a/std/deflate/decode_huffman_fast64.wuffs +++ b/std/deflate/decode_huffman_fast64.wuffs @@ -218,18 +218,14 @@ pri func decoder.decode_huffman_fast64!(dst: base.io_writer, src: base.io_reader if this.history_index < hdist { return "#bad distance" } - // Re-purpose the hdist variable as the this.history index to - // start copying from. - hdist = this.history_index - hdist - // Copy from hdist to the end of this.history. + // Copy from this.history[(this.history_index - hdist) ..]. // // This copying is simpler than the decode_huffman_slow version // because it cannot yield. We have already checked that // args.dst.length() is large enough. args.dst.limited_copy_u32_from_slice!( - up_to: hlen, s: this.history[hdist & 0x7FFF ..]) - + up_to: hlen, s: this.history[(this.history_index - hdist) & 0x7FFF ..]) if length == 0 { // No need to copy from args.dst. continue.loop diff --git a/std/deflate/decode_huffman_slow.wuffs b/std/deflate/decode_huffman_slow.wuffs index 4f653e50..1a4afb1f 100644 --- a/std/deflate/decode_huffman_slow.wuffs +++ b/std/deflate/decode_huffman_slow.wuffs @@ -220,13 +220,10 @@ pri func decoder.decode_huffman_slow?(dst: base.io_writer, src: base.io_reader) if this.history_index < hdist { return "#bad distance" } - // Re-purpose the hdist variable as the this.history index to - // start copying from. - hdist = this.history_index - hdist - // Copy from hdist to the end of this.history. + // Copy from this.history[(this.history_index - hdist) ..]. n_copied = args.dst.limited_copy_u32_from_slice!( - up_to: hlen, s: this.history[hdist & 0x7FFF ..]) + up_to: hlen, s: this.history[(this.history_index - hdist) & 0x7FFF ..]) if n_copied < hlen { assert n_copied < length via "a < b: a < c; c <= b"(c: hlen) assert length > n_copied via "a > b: b < a"()