mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-21 08:47:28 +01:00
Prepare decode_huffman_fast to rewind in.src.
This commit is contained in:
1 parent
3099991d7f
commit
325c36314a
3 files changed
+22
-1
No files matched your search
@@ -291,7 +291,23 @@ pri func flate_decoder.decode_huffman_fast?(dst writer1, src reader1)() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: unread some in.src bytes if n_bits >= 8?
|
||||
// Ensure n_bits < 8 by rewindng in.src, if we loaded too many of its bytes
|
||||
// into the bits variable.
|
||||
//
|
||||
// Note that we can unconditionally call unread_u8 (without resulting in an
|
||||
// "invalid I/O operation" error code) only because this whole function can
|
||||
// never suspend, as all of its I/O operations were checked beforehand for
|
||||
// sufficient buffer space. Otherwise, resuming from the suspension could
|
||||
// mean that the (possibly different) in.src is no longer rewindable, even
|
||||
// if conceptually, this function was responsible for reading the bytes we
|
||||
// want to rewind.
|
||||
//
|
||||
// TODO: have the compiler enforce (via some explicit syntax) that this
|
||||
// function is ProvenNotToSuspend?
|
||||
while n_bits >= 8 {
|
||||
n_bits -= 8
|
||||
// TODO: in.src.unread_u8?()
|
||||
}
|
||||
|
||||
this.bits = bits
|
||||
this.n_bits = n_bits
|
||||
|
||||
@@ -252,6 +252,8 @@ pri func flate_decoder.decode_huffman_slow?(dst writer1, src reader1)() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: "assert n_bits < 8"?
|
||||
|
||||
this.bits = bits
|
||||
this.n_bits = n_bits
|
||||
|
||||
|
||||
Reference in new issue
Block a user