mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 08:47:56 +01:00
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:
1 parent
010e0a69f4
commit
bb8623b472
2 files changed
+5
-34
No files matched your search
@@ -28152,7 +28152,7 @@ wuffs_deflate__decoder__decode_huffman_slow(
|
|||||||
v_hdist = (self->private_impl.f_history_index - v_hdist);
|
v_hdist = (self->private_impl.f_history_index - v_hdist);
|
||||||
while (true) {
|
while (true) {
|
||||||
v_n_copied = wuffs_base__io_writer__limited_copy_u32_from_slice(
|
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) {
|
if (v_hlen <= v_n_copied) {
|
||||||
v_hlen = 0;
|
v_hlen = 0;
|
||||||
goto label__4__break;
|
goto label__4__break;
|
||||||
@@ -28168,21 +28168,6 @@ wuffs_deflate__decoder__decode_huffman_slow(
|
|||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(9);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(9);
|
||||||
}
|
}
|
||||||
label__4__break:;
|
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) {
|
if (v_length == 0) {
|
||||||
goto label__loop__continue;
|
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));
|
&iop_a_dst, io0_a_dst, io2_a_dst, v_length, (v_dist_minus_1 + 1));
|
||||||
if (v_length <= v_n_copied) {
|
if (v_length <= v_n_copied) {
|
||||||
v_length = 0;
|
v_length = 0;
|
||||||
goto label__6__break;
|
goto label__5__break;
|
||||||
}
|
}
|
||||||
v_length -= v_n_copied;
|
v_length -= v_n_copied;
|
||||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
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:;
|
label__loop__break:;
|
||||||
self->private_impl.f_bits = v_bits;
|
self->private_impl.f_bits = v_bits;
|
||||||
|
|||||||
@@ -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.
|
// Copy from hdist to the end of this.history.
|
||||||
while true {
|
while true {
|
||||||
n_copied = args.dst.limited_copy_u32_from_slice!(
|
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 {
|
if hlen <= n_copied {
|
||||||
hlen = 0
|
hlen = 0
|
||||||
break
|
break
|
||||||
@@ -243,20 +243,6 @@ pri func decoder.decode_huffman_slow?(dst: base.io_writer, src: base.io_reader)
|
|||||||
}
|
}
|
||||||
yield? base."$short write"
|
yield? base."$short write"
|
||||||
} endwhile
|
} 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 {
|
if length == 0 {
|
||||||
// No need to copy from args.dst.
|
// No need to copy from args.dst.
|
||||||
|
|||||||
Reference in new issue
Block a user