mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 08:47:56 +01:00
Call copy_history32 in a trival 1-iteration loop.
Follow-up commits will re-try copy_history32's across I/O boundaries.
This commit is contained in:
1 parent
d30d4c3dad
commit
a1271222a4
2 files changed
+46
-37
No files matched your search
+41
-35
@@ -1314,46 +1314,52 @@ puffs_flate_status puffs_flate_decoder_decode_huffman(
|
|||||||
v_distance += ((v_bits) & ((1 << (v_table_entry_n_bits)) - 1));
|
v_distance += ((v_bits) & ((1 << (v_table_entry_n_bits)) - 1));
|
||||||
v_bits >>= v_table_entry_n_bits;
|
v_bits >>= v_table_entry_n_bits;
|
||||||
v_n_bits -= v_table_entry_n_bits;
|
v_n_bits -= v_table_entry_n_bits;
|
||||||
if (((uint64_t)(v_distance)) > ((uint64_t)(b_wptr_dst - b_wstart_dst))) {
|
while (true) {
|
||||||
}
|
if (((uint64_t)(v_distance)) >
|
||||||
PUFFS_COROUTINE_SUSPENSION_POINT(8);
|
((uint64_t)(b_wptr_dst - b_wstart_dst))) {
|
||||||
{
|
|
||||||
self->private_impl.c_decode_huffman[0].scratch =
|
|
||||||
((uint64_t)(v_distance) << 32) | (uint64_t)(v_length);
|
|
||||||
PUFFS_COROUTINE_SUSPENSION_POINT(9);
|
|
||||||
size_t t_6 =
|
|
||||||
(size_t)(self->private_impl.c_decode_huffman[0].scratch >> 32);
|
|
||||||
if (PUFFS_UNLIKELY((t_6 == 0) || (t_6 > (b_wptr_dst - b_wstart_dst)))) {
|
|
||||||
status = PUFFS_FLATE_ERROR_BAD_ARGUMENT;
|
|
||||||
goto exit;
|
|
||||||
}
|
}
|
||||||
uint8_t* t_7 = b_wptr_dst - t_6;
|
PUFFS_COROUTINE_SUSPENSION_POINT(8);
|
||||||
uint32_t t_8 =
|
{
|
||||||
(uint32_t)(self->private_impl.c_decode_huffman[0].scratch);
|
self->private_impl.c_decode_huffman[0].scratch =
|
||||||
if (PUFFS_LIKELY((size_t)(t_8) <= (b_wend_dst - b_wptr_dst))) {
|
((uint64_t)(v_distance) << 32) | (uint64_t)(v_length);
|
||||||
for (; t_8 >= 8; t_8 -= 8) {
|
PUFFS_COROUTINE_SUSPENSION_POINT(9);
|
||||||
*b_wptr_dst++ = *t_7++;
|
size_t t_6 =
|
||||||
*b_wptr_dst++ = *t_7++;
|
(size_t)(self->private_impl.c_decode_huffman[0].scratch >> 32);
|
||||||
*b_wptr_dst++ = *t_7++;
|
if (PUFFS_UNLIKELY((t_6 == 0) ||
|
||||||
*b_wptr_dst++ = *t_7++;
|
(t_6 > (b_wptr_dst - b_wstart_dst)))) {
|
||||||
*b_wptr_dst++ = *t_7++;
|
status = PUFFS_FLATE_ERROR_BAD_ARGUMENT;
|
||||||
*b_wptr_dst++ = *t_7++;
|
goto exit;
|
||||||
*b_wptr_dst++ = *t_7++;
|
|
||||||
*b_wptr_dst++ = *t_7++;
|
|
||||||
}
|
}
|
||||||
for (; t_8; t_8--) {
|
uint8_t* t_7 = b_wptr_dst - t_6;
|
||||||
*b_wptr_dst++ = *t_7++;
|
uint32_t t_8 =
|
||||||
|
(uint32_t)(self->private_impl.c_decode_huffman[0].scratch);
|
||||||
|
if (PUFFS_LIKELY((size_t)(t_8) <= (b_wend_dst - b_wptr_dst))) {
|
||||||
|
for (; t_8 >= 8; t_8 -= 8) {
|
||||||
|
*b_wptr_dst++ = *t_7++;
|
||||||
|
*b_wptr_dst++ = *t_7++;
|
||||||
|
*b_wptr_dst++ = *t_7++;
|
||||||
|
*b_wptr_dst++ = *t_7++;
|
||||||
|
*b_wptr_dst++ = *t_7++;
|
||||||
|
*b_wptr_dst++ = *t_7++;
|
||||||
|
*b_wptr_dst++ = *t_7++;
|
||||||
|
*b_wptr_dst++ = *t_7++;
|
||||||
|
}
|
||||||
|
for (; t_8; t_8--) {
|
||||||
|
*b_wptr_dst++ = *t_7++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
t_8 = (uint32_t)(b_wend_dst - b_wptr_dst);
|
||||||
|
self->private_impl.c_decode_huffman[0].scratch -= (uint64_t)(t_8);
|
||||||
|
for (; t_8; t_8--) {
|
||||||
|
*b_wptr_dst++ = *t_7++;
|
||||||
|
}
|
||||||
|
status = PUFFS_FLATE_SUSPENSION_SHORT_WRITE;
|
||||||
|
goto suspend;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
t_8 = (uint32_t)(b_wend_dst - b_wptr_dst);
|
|
||||||
self->private_impl.c_decode_huffman[0].scratch -= (uint64_t)(t_8);
|
|
||||||
for (; t_8; t_8--) {
|
|
||||||
*b_wptr_dst++ = *t_7++;
|
|
||||||
}
|
|
||||||
status = PUFFS_FLATE_SUSPENSION_SHORT_WRITE;
|
|
||||||
goto suspend;
|
|
||||||
}
|
}
|
||||||
|
goto label_5_break;
|
||||||
}
|
}
|
||||||
|
label_5_break:;
|
||||||
}
|
}
|
||||||
label_0_break:;
|
label_0_break:;
|
||||||
self->private_impl.f_bits = v_bits;
|
self->private_impl.f_bits = v_bits;
|
||||||
|
|||||||
@@ -341,9 +341,12 @@ pri func decoder.decode_huffman?(dst writer1, src reader1)() {
|
|||||||
// TODO: copy_history32 should also take some notion of how much of dst
|
// 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
|
// is valid. When copying from a distance greater than that, we also
|
||||||
// need to keep a sliding window of previous history.
|
// need to keep a sliding window of previous history.
|
||||||
if (distance as u64) > in.dst.length() {
|
while true {
|
||||||
|
if (distance as u64) > in.dst.length() {
|
||||||
|
}
|
||||||
|
in.dst.copy_history32?(distance:distance, length:length)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
in.dst.copy_history32?(distance:distance, length:length)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bits = bits
|
this.bits = bits
|
||||||
|
|||||||
Reference in new issue
Block a user