Have deflate slow-Huffman use extended ringbuffer

This is the same optimization as commit e65c8612 "Extend std/deflate
ringbuffer to simplify copies", applied to decoder.decode_huffman_slow.
This commit is contained in:
Nigel Tao committed 2021-11-20 20:10:10 +11:00
1 parent 010e0a69f4
commit bb8623b472
2 files changed
+5 -34

No files matched your search

+4 -19
View File
@@ -28152,7 +28152,7 @@ wuffs_deflate__decoder__decode_huffman_slow(
v_hdist = (self->private_impl.f_history_index - v_hdist);
while (true) {
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, 32768), (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), (v_hdist & 32767)));
if (v_hlen <= v_n_copied) {
v_hlen = 0;
goto label__4__break;
@@ -28168,21 +28168,6 @@ wuffs_deflate__decoder__decode_huffman_slow(
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(9);
}
label__4__break:;
if (v_hlen > 0) {
while (true) {
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, 32768), (v_hdist & 32767)));
if (v_hlen <= v_n_copied) {
v_hlen = 0;
goto label__5__break;
}
v_hlen -= v_n_copied;
v_hdist += v_n_copied;
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(10);
}
label__5__break:;
}
if (v_length == 0) {
goto label__loop__continue;
}
@@ -28191,13 +28176,13 @@ wuffs_deflate__decoder__decode_huffman_slow(
&iop_a_dst, io0_a_dst, io2_a_dst, v_length, (v_dist_minus_1 + 1));
if (v_length <= v_n_copied) {
v_length = 0;
goto label__6__break;
goto label__5__break;
}
v_length -= v_n_copied;
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(11);
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(10);
}
label__6__break:;
label__5__break:;
}
label__loop__break:;
self->private_impl.f_bits = v_bits;
+1 -15
View File
@@ -228,7 +228,7 @@ pri func decoder.decode_huffman_slow?(dst: base.io_writer, src: base.io_reader)
// Copy from hdist to the end of this.history.
while true {
n_copied = args.dst.limited_copy_u32_from_slice!(
up_to: hlen, s: this.history[hdist & 0x7FFF .. 0x8000])
up_to: hlen, s: this.history[hdist & 0x7FFF ..])
if hlen <= n_copied {
hlen = 0
break
@@ -243,20 +243,6 @@ pri func decoder.decode_huffman_slow?(dst: base.io_writer, src: base.io_reader)
}
yield? base."$short write"
} endwhile
// Copy from the start of this.history, if we wrapped around.
if hlen > 0 {
while true {
n_copied = args.dst.limited_copy_u32_from_slice!(
up_to: hlen, s: this.history[hdist & 0x7FFF .. 0x8000])
if hlen <= n_copied {
hlen = 0
break
}
hlen -= n_copied
hdist ~mod+= n_copied
yield? base."$short write"
} endwhile
}
if length == 0 {
// No need to copy from args.dst.