Remove the write_to_ib_instead_of_w hack

This commit is contained in:
Nigel Tao committed 2018-05-29 08:26:27 +10:00
1 parent 47cf248e57
commit c5362d6413
4 files changed
+17 -112

No files matched your search

+2 -26
View File
@@ -420,10 +420,6 @@ pri func decoder.decode_id_part1?(ib ptr base.image_buffer, dst base.io_writer,
}
this.lzw.set_literal_width!(lw:lw as base.u32)
// TODO: delete the write_to_ib_instead_of_w hack. It should always be
// true.
var write_to_ib_instead_of_w base.bool = true
this.previous_lzw_decode_ended_abruptly = true
while true {
var block_size base.u64 = in.src.read_u8?() as base.u64
@@ -450,27 +446,7 @@ pri func decoder.decode_id_part1?(ib ptr base.image_buffer, dst base.io_writer,
}
if z.is_ok() or (z == suspension "short write") {
// Pass through the uncompressed bytes to in.dst.
//
// TODO: in.dst should be a ptr base.image_buffer and we should
// composite the pixels instead of just copying them.
if not write_to_ib_instead_of_w {
while this.uncompressed_ri < this.uncompressed_wi {
var pass_through slice base.u8 = this.uncompressed[this.uncompressed_ri:this.uncompressed_wi]
var n_copied base.u64 = in.dst.copy_from_slice!(s:pass_through)
if n_copied == pass_through.length() {
this.uncompressed_ri = 0
this.uncompressed_wi = 0
break
}
this.uncompressed_ri = (this.uncompressed_ri + ((n_copied & 4095) as base.u32)) & 4095
// TODO: "closed for writes" instead?
yield suspension "short write"
}
} else {
this.copy_to_image_buffer?(ib:in.ib)
}
this.copy_to_image_buffer?(ib:in.ib)
if z == suspension "short write" {
continue:inner
@@ -486,7 +462,7 @@ pri func decoder.decode_id_part1?(ib ptr base.image_buffer, dst base.io_writer,
}
}
if (this.uncompressed_ri != this.uncompressed_wi) and write_to_ib_instead_of_w {
if this.uncompressed_ri != this.uncompressed_wi {
this.copy_to_image_buffer?(ib:in.ib)
}