mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 00:32:11 +01:00
Use peek_uxx_as_uyy more often
This commit is contained in:
1 parent
86a96969cc
commit
2f4c931b42
3 files changed
+15
-16
No files matched your search
@@ -7227,8 +7227,7 @@ wuffs_lzw__decoder__decode(wuffs_lzw__decoder* self,
|
||||
while (true) {
|
||||
if (v_n_bits < v_width) {
|
||||
if (((uint64_t)(io1_a_src - iop_a_src)) >= 4) {
|
||||
v_bits |=
|
||||
(((uint32_t)(wuffs_base__load_u32le(iop_a_src))) << v_n_bits);
|
||||
v_bits |= (wuffs_base__load_u32le(iop_a_src) << v_n_bits);
|
||||
(iop_a_src += ((31 - v_n_bits) >> 3),
|
||||
wuffs_base__return_empty_struct());
|
||||
v_n_bits |= 24;
|
||||
|
||||
@@ -63,10 +63,10 @@ pri func decoder.decode_huffman_fast!?(dst base.io_writer, src base.io_reader) {
|
||||
// Ensure that we have at least 15 bits of input.
|
||||
if n_bits < 15 {
|
||||
assert n_bits >= 0 // TODO: this shouldn't be necessary.
|
||||
bits |= (args.src.peek_u8() as base.u32) << n_bits
|
||||
bits |= args.src.peek_u8_as_u32() << n_bits
|
||||
args.src.skip_fast!(actual:1, worst_case:1)
|
||||
n_bits += 8
|
||||
bits |= (args.src.peek_u8() as base.u32) << n_bits
|
||||
bits |= args.src.peek_u8_as_u32() << n_bits
|
||||
args.src.skip_fast!(actual:1, worst_case:1)
|
||||
n_bits += 8
|
||||
assert n_bits >= 15
|
||||
@@ -102,10 +102,10 @@ pri func decoder.decode_huffman_fast!?(dst base.io_writer, src base.io_reader) {
|
||||
// Ensure that we have at least 15 bits of input.
|
||||
if n_bits < 15 {
|
||||
assert n_bits >= 0 // TODO: this shouldn't be necessary.
|
||||
bits |= (args.src.peek_u8() as base.u32) << n_bits
|
||||
bits |= args.src.peek_u8_as_u32() << n_bits
|
||||
args.src.skip_fast!(actual:1, worst_case:1)
|
||||
n_bits += 8
|
||||
bits |= (args.src.peek_u8() as base.u32) << n_bits
|
||||
bits |= args.src.peek_u8_as_u32() << n_bits
|
||||
args.src.skip_fast!(actual:1, worst_case:1)
|
||||
n_bits += 8
|
||||
assert n_bits >= 15
|
||||
@@ -163,10 +163,10 @@ pri func decoder.decode_huffman_fast!?(dst base.io_writer, src base.io_reader) {
|
||||
// Ensure that we have at least 15 bits of input.
|
||||
if n_bits < 15 {
|
||||
assert n_bits >= 0 // TODO: this shouldn't be necessary.
|
||||
bits |= (args.src.peek_u8() as base.u32) << n_bits
|
||||
bits |= args.src.peek_u8_as_u32() << n_bits
|
||||
args.src.skip_fast!(actual:1, worst_case:1)
|
||||
n_bits += 8
|
||||
bits |= (args.src.peek_u8() as base.u32) << n_bits
|
||||
bits |= args.src.peek_u8_as_u32() << n_bits
|
||||
args.src.skip_fast!(actual:1, worst_case:1)
|
||||
n_bits += 8
|
||||
assert n_bits >= 15
|
||||
@@ -190,10 +190,10 @@ pri func decoder.decode_huffman_fast!?(dst base.io_writer, src base.io_reader) {
|
||||
// Ensure that we have at least 15 bits of input.
|
||||
if n_bits < 15 {
|
||||
assert n_bits >= 0 // TODO: this shouldn't be necessary.
|
||||
bits |= (args.src.peek_u8() as base.u32) << n_bits
|
||||
bits |= args.src.peek_u8_as_u32() << n_bits
|
||||
args.src.skip_fast!(actual:1, worst_case:1)
|
||||
n_bits += 8
|
||||
bits |= (args.src.peek_u8() as base.u32) << n_bits
|
||||
bits |= args.src.peek_u8_as_u32() << n_bits
|
||||
args.src.skip_fast!(actual:1, worst_case:1)
|
||||
n_bits += 8
|
||||
assert n_bits >= 15
|
||||
@@ -215,10 +215,10 @@ pri func decoder.decode_huffman_fast!?(dst base.io_writer, src base.io_reader) {
|
||||
// Ensure that we have at least 15 bits of input.
|
||||
if n_bits < 15 {
|
||||
assert n_bits >= 0 // TODO: this shouldn't be necessary.
|
||||
bits |= (args.src.peek_u8() as base.u32) << n_bits
|
||||
bits |= args.src.peek_u8_as_u32() << n_bits
|
||||
args.src.skip_fast!(actual:1, worst_case:1)
|
||||
n_bits += 8
|
||||
bits |= (args.src.peek_u8() as base.u32) << n_bits
|
||||
bits |= args.src.peek_u8_as_u32() << n_bits
|
||||
args.src.skip_fast!(actual:1, worst_case:1)
|
||||
n_bits += 8
|
||||
assert n_bits >= 15
|
||||
@@ -262,10 +262,10 @@ pri func decoder.decode_huffman_fast!?(dst base.io_writer, src base.io_reader) {
|
||||
if n_bits < table_entry_n_bits {
|
||||
assert n_bits < 15 via "a < b: a < c; c <= b"(c:table_entry_n_bits)
|
||||
assert n_bits >= 0 // TODO: this shouldn't be necessary.
|
||||
bits |= (args.src.peek_u8() as base.u32) << n_bits
|
||||
bits |= args.src.peek_u8_as_u32() << n_bits
|
||||
args.src.skip_fast!(actual:1, worst_case:1)
|
||||
n_bits += 8
|
||||
bits |= (args.src.peek_u8() as base.u32) << n_bits
|
||||
bits |= args.src.peek_u8_as_u32() << n_bits
|
||||
args.src.skip_fast!(actual:1, worst_case:1)
|
||||
n_bits += 8
|
||||
assert table_entry_n_bits <= n_bits via "a <= b: a <= c; c <= b"(c:16)
|
||||
|
||||
@@ -72,7 +72,7 @@ pub func decoder.decode!??(dst base.io_writer, src base.io_reader) {
|
||||
if args.src.available() >= 4 {
|
||||
// Read 4 bytes, using the "Variant 4" technique of
|
||||
// https://fgiesen.wordpress.com/2018/02/20/reading-bits-in-far-too-many-ways-part-2/
|
||||
bits |= (args.src.peek_u32le() as base.u32) ~mod<< n_bits
|
||||
bits |= args.src.peek_u32le() ~mod<< n_bits
|
||||
args.src.skip_fast!(actual:(31 - n_bits) >> 3, worst_case:3)
|
||||
n_bits |= 24
|
||||
assert width <= n_bits via "a <= b: a <= c; c <= b"(c:12)
|
||||
@@ -98,7 +98,7 @@ pub func decoder.decode!??(dst base.io_writer, src base.io_reader) {
|
||||
yield base."$short read"
|
||||
}
|
||||
}
|
||||
bits |= (args.src.peek_u8() as base.u32) << n_bits
|
||||
bits |= args.src.peek_u8_as_u32() << n_bits
|
||||
args.src.skip_fast!(actual:1, worst_case:1)
|
||||
n_bits += 8
|
||||
if n_bits >= width {
|
||||
|
||||
Reference in new issue
Block a user