mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 16:32:11 +01:00
Drop the "?" from "copy_history32?".
This makes the caller, not the implementation, responsible for detecting short reads and writes. This (the lack of "?") is consistent with the slice.copy_from method. name old speed new speed delta puffs_flate_decode_1k/clang 117MB/s ± 6% 120MB/s ± 0% +2.31% (p=0.016 n=5+5) puffs_flate_decode_10k/clang 153MB/s ± 1% 155MB/s ± 0% +1.16% (p=0.008 n=5+5) puffs_flate_decode_100k/clang 168MB/s ± 1% 177MB/s ± 0% +5.41% (p=0.008 n=5+5) puffs_flate_decode_1k/gcc 127MB/s ± 1% 143MB/s ± 0% +12.15% (p=0.008 n=5+5) puffs_flate_decode_10k/gcc 145MB/s ± 0% 180MB/s ± 1% +24.00% (p=0.008 n=5+5) puffs_flate_decode_100k/gcc 163MB/s ± 0% 212MB/s ± 1% +29.90% (p=0.008 n=5+5)
This commit is contained in:
1 parent
a1271222a4
commit
2e883fcc23
11 files changed
+155
-116
No files matched your search
@@ -191,6 +191,7 @@ pri func decoder.decode_uncompressed?(dst writer1, src reader1)() {
|
||||
if (n.low_bits(n:16) + n.high_bits(n:16)) != 0xFFFF {
|
||||
return error "inconsistent stored block length"
|
||||
}
|
||||
// TODO: drop the "?" from "copy_from32?"?
|
||||
in.dst.copy_from32?(r:in.src, n:n.low_bits(n:16))
|
||||
}
|
||||
|
||||
@@ -338,14 +339,22 @@ pri func decoder.decode_huffman?(dst writer1, src reader1)() {
|
||||
bits >>= table_entry_n_bits
|
||||
n_bits -= table_entry_n_bits
|
||||
|
||||
// TODO: copy_history32 should also take some notion of how much of dst
|
||||
// is valid. When copying from a distance greater than that, we also
|
||||
// need to keep a sliding window of previous history.
|
||||
while true {
|
||||
if (distance as u64) > in.dst.length() {
|
||||
// TODO: copy from this.history.
|
||||
}
|
||||
in.dst.copy_history32?(distance:distance, length:length)
|
||||
break
|
||||
var n u32 = in.dst.copy_history32(distance:distance, length:length)
|
||||
if length == n {
|
||||
break
|
||||
} else if length < n {
|
||||
return error "internal error: inconsistent Huffman decoder state"
|
||||
}
|
||||
length -= n
|
||||
// TODO: distinguish between short and limited writes?
|
||||
//
|
||||
// TODO: return suspension "short write" instead of this bogus
|
||||
// return error "bad Huffman code".
|
||||
return error "bad Huffman code"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user