Skip to content

Commit

Permalink
simplify code via the new read_u24le
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdan committed Jun 2, 2018
1 parent 55ba7e0 commit 9f48d9a
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions decode.wuffs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,9 @@ pub func decoder.decode?(dst base.io_writer, src base.io_reader)() {
// TODO: possibly read dictionary ID

while true {
// spaghetti code to read a three-byte little endian number
var block_lower base.u32[..0xFF] = in.src.read_u8?() as base.u32
var block_upper base.u32[..0xFFFF] = in.src.read_u16le?() as base.u32
var block_header base.u32[..0xFFFFFF] = (block_upper << 8) | block_lower
var block_header base.u32[..0xFFFFFF] = in.src.read_u24le?()

var is_last_block base.bool = (block_header & 1) == 1

var block_type base.u8[..0x3] = ((block_header >> 1) & 3) as base.u8

var block_size base.u32[..0x1FFFFF] = block_header >> 3
Expand Down

0 comments on commit 9f48d9a

Please sign in to comment.