mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 00:55:11 +01:00
Optimize deflate Huffman; remove unnecessary if
name old speed new speed delta wuffs_deflate_decode_1k/clang 150MB/s ± 0% 148MB/s ± 0% -1.50% (p=0.008 n=5+5) wuffs_deflate_decode_10k/clang 223MB/s ± 0% 228MB/s ± 1% +1.92% (p=0.008 n=5+5) wuffs_deflate_decode_100k/clang 243MB/s ± 0% 253MB/s ± 0% +4.50% (p=0.008 n=5+5) wuffs_deflate_decode_1k/gcc 157MB/s ± 0% 158MB/s ± 1% +0.67% (p=0.008 n=5+5) wuffs_deflate_decode_10k/gcc 265MB/s ± 0% 265MB/s ± 0% ~ (p=0.095 n=5+5) wuffs_deflate_decode_100k/gcc 299MB/s ± 0% 300MB/s ± 0% ~ (p=0.056 n=5+5)
This commit is contained in:
1 parent
c89833331c
commit
0181537d0d
2 files changed
+27
-31
No files matched your search
@@ -5958,21 +5958,19 @@ label_0_continue:;
|
|||||||
}
|
}
|
||||||
v_dist_minus_1 = ((v_table_entry >> 8) & 32767);
|
v_dist_minus_1 = ((v_table_entry >> 8) & 32767);
|
||||||
v_table_entry_n_bits = ((v_table_entry >> 4) & 15);
|
v_table_entry_n_bits = ((v_table_entry >> 4) & 15);
|
||||||
if (v_table_entry_n_bits > 0) {
|
if (v_n_bits < 15) {
|
||||||
if (v_n_bits < 15) {
|
v_bits |= (((uint32_t)(wuffs_base__load_u8be(iop_a_src))) << v_n_bits);
|
||||||
v_bits |= (((uint32_t)(wuffs_base__load_u8be(iop_a_src))) << v_n_bits);
|
(iop_a_src += 1, wuffs_base__return_empty_struct());
|
||||||
(iop_a_src += 1, wuffs_base__return_empty_struct());
|
v_n_bits += 8;
|
||||||
v_n_bits += 8;
|
v_bits |= (((uint32_t)(wuffs_base__load_u8be(iop_a_src))) << v_n_bits);
|
||||||
v_bits |= (((uint32_t)(wuffs_base__load_u8be(iop_a_src))) << v_n_bits);
|
(iop_a_src += 1, wuffs_base__return_empty_struct());
|
||||||
(iop_a_src += 1, wuffs_base__return_empty_struct());
|
v_n_bits += 8;
|
||||||
v_n_bits += 8;
|
|
||||||
}
|
|
||||||
v_dist_minus_1 =
|
|
||||||
((v_dist_minus_1 + ((v_bits) & ((1 << (v_table_entry_n_bits)) - 1))) &
|
|
||||||
32767);
|
|
||||||
v_bits >>= v_table_entry_n_bits;
|
|
||||||
v_n_bits -= v_table_entry_n_bits;
|
|
||||||
}
|
}
|
||||||
|
v_dist_minus_1 =
|
||||||
|
((v_dist_minus_1 + ((v_bits) & ((1 << (v_table_entry_n_bits)) - 1))) &
|
||||||
|
32767);
|
||||||
|
v_bits >>= v_table_entry_n_bits;
|
||||||
|
v_n_bits -= v_table_entry_n_bits;
|
||||||
v_n_copied = 0;
|
v_n_copied = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (((uint64_t)((v_dist_minus_1 + 1))) >
|
if (((uint64_t)((v_dist_minus_1 + 1))) >
|
||||||
|
|||||||
@@ -256,25 +256,23 @@ pri func decoder.decode_huffman_fast!??(dst base.io_writer, src base.io_reader)
|
|||||||
// undoing that bias makes proving (dist_minus_1 + 1) > 0 trivial.
|
// undoing that bias makes proving (dist_minus_1 + 1) > 0 trivial.
|
||||||
var dist_minus_1 base.u32[..0x7FFF] = (table_entry >> 8) & 0x7FFF
|
var dist_minus_1 base.u32[..0x7FFF] = (table_entry >> 8) & 0x7FFF
|
||||||
table_entry_n_bits = (table_entry >> 4) & 0x0F
|
table_entry_n_bits = (table_entry >> 4) & 0x0F
|
||||||
if table_entry_n_bits > 0 {
|
// Ensure that we have at least 15 bits of input.
|
||||||
// Ensure that we have at least 15 bits of input.
|
if n_bits < 15 {
|
||||||
if n_bits < 15 {
|
assert n_bits >= 0 // TODO: this shouldn't be necessary.
|
||||||
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 base.u32) << n_bits
|
args.src.skip_fast!(actual:1, worst_case:1)
|
||||||
args.src.skip_fast!(actual:1, worst_case:1)
|
n_bits += 8
|
||||||
n_bits += 8
|
bits |= (args.src.peek_u8() as base.u32) << n_bits
|
||||||
bits |= (args.src.peek_u8() as base.u32) << n_bits
|
args.src.skip_fast!(actual:1, worst_case:1)
|
||||||
args.src.skip_fast!(actual:1, worst_case:1)
|
n_bits += 8
|
||||||
n_bits += 8
|
|
||||||
assert n_bits >= 15
|
|
||||||
}
|
|
||||||
// Once again, redundant but explicit assertions.
|
|
||||||
assert n_bits >= 15
|
assert n_bits >= 15
|
||||||
|
|
||||||
dist_minus_1 = (dist_minus_1 + bits.low_bits(n:table_entry_n_bits)) & 0x7FFF
|
|
||||||
bits >>= table_entry_n_bits
|
|
||||||
n_bits -= table_entry_n_bits
|
|
||||||
}
|
}
|
||||||
|
// Once again, redundant but explicit assertions.
|
||||||
|
assert n_bits >= 15
|
||||||
|
|
||||||
|
dist_minus_1 = (dist_minus_1 + bits.low_bits(n:table_entry_n_bits)) & 0x7FFF
|
||||||
|
bits >>= table_entry_n_bits
|
||||||
|
n_bits -= table_entry_n_bits
|
||||||
|
|
||||||
var n_copied base.u32
|
var n_copied base.u32
|
||||||
// The "while true { etc; break }" is a redundant version of "etc", but
|
// The "while true { etc; break }" is a redundant version of "etc", but
|
||||||
|
|||||||
Reference in new issue
Block a user