Drop std/deflate's "Re-purpose the hdist variable"

This commit is contained in:
Nigel Tao committed 2021-11-20 22:03:29 +11:00
1 parent 49a431f98d
commit 5e8b448c12
5 files changed
+12 -31

No files matched your search

+2 -6
View File
@@ -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
+2 -6
View File
@@ -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
+2 -6
View File
@@ -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
+2 -5
View File
@@ -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"()