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

+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.