mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-20 16:47:28 +01:00
Add a writer1.is_marked method.
This commit is contained in:
1 parent
545f043d94
commit
e2ce9f1b1d
7 files changed
+38
-5
No files matched your search
@@ -20,6 +20,11 @@ pri func flate_decoder.decode_huffman_fast?(dst writer1, src reader1)() {
|
||||
// decode_huffman_*.puffs files as small as possible, while retaining both
|
||||
// correctness and performance.
|
||||
|
||||
// TODO: make this a func pre-condition.
|
||||
if in.dst.is_marked() != true { // TODO: if not in.dst.is_marked() {
|
||||
return error "bad argument"
|
||||
}
|
||||
|
||||
if (this.n_bits >= 8) or ((this.bits >> this.n_bits) != 0) {
|
||||
return error "internal error: inconsistent n_bits"
|
||||
}
|
||||
@@ -59,7 +64,9 @@ pri func flate_decoder.decode_huffman_fast?(dst writer1, src reader1)() {
|
||||
// for each. There are also up to 13 extra bits, or 2 bytes. Thus, each
|
||||
// code requires up to 2 + 2 + 2 == 6 bytes, and there are two codes (one
|
||||
// from H-L and one from H-D). Therefore, we check for at least 12 bytes.
|
||||
while:loop(in.dst.available() >= 258) and (in.src.available() >= 12) {
|
||||
while:loop(in.dst.available() >= 258) and (in.src.available() >= 12),
|
||||
inv in.dst.is_marked() == true, // TODO: remove the redundant "== true".
|
||||
{
|
||||
// Ensure that we have at least 15 bits of input.
|
||||
if n_bits < 15 {
|
||||
assert n_bits >= 0 // TODO: this shouldn't be necessary.
|
||||
@@ -260,7 +267,9 @@ pri func flate_decoder.decode_huffman_fast?(dst writer1, src reader1)() {
|
||||
// The "while true { etc; break }" is a redundant version of "etc", but
|
||||
// its presence minimizes the diff between decode_huffman_fast and
|
||||
// decode_huffman_slow.
|
||||
while true {
|
||||
while true,
|
||||
inv in.dst.is_marked() == true,
|
||||
{
|
||||
// Copy from this.history.
|
||||
if (distance as u64) > in.dst.since_mark().length() {
|
||||
// Set (hlen, hdist) to be the length-distance pair to copy
|
||||
@@ -288,7 +297,9 @@ pri func flate_decoder.decode_huffman_fast?(dst writer1, src reader1)() {
|
||||
// The "while true { etc; break }" is a redundant version of
|
||||
// "etc", but its presence minimizes the diff between
|
||||
// decode_huffman_fast and decode_huffman_slow.
|
||||
while true {
|
||||
while true,
|
||||
inv in.dst.is_marked() == true,
|
||||
{
|
||||
n_copied = in.dst.copy_from_slice32(s:this.history[hdist:], length:hlen)
|
||||
if hlen <= n_copied {
|
||||
break
|
||||
|
||||
Reference in new issue
Block a user