Rename copy_n32_etc to limited_copy_u32_etc

This commit is contained in:
Nigel Tao committed 2020-05-27 19:55:06 +10:00
1 parent e74fd729a7
commit 1ed0f89948
10 files changed
+97 -95

No files matched your search

+31 -31
View File
@@ -7738,11 +7738,11 @@ wuffs_base__io_writer__copy_from_slice(uint8_t** ptr_iop_w,
}
static inline uint32_t //
wuffs_base__io_writer__copy_n32_from_history(uint8_t** ptr_iop_w,
uint8_t* io1_w,
uint8_t* io2_w,
uint32_t length,
uint32_t distance) {
wuffs_base__io_writer__limited_copy_u32_from_history(uint8_t** ptr_iop_w,
uint8_t* io1_w,
uint8_t* io2_w,
uint32_t length,
uint32_t distance) {
if (!distance) {
return 0;
}
@@ -7760,14 +7760,14 @@ wuffs_base__io_writer__copy_n32_from_history(uint8_t** ptr_iop_w,
// TODO: unrolling by 3 seems best for the std/deflate benchmarks, but that
// is mostly because 3 is the minimum length for the deflate format. This
// function implementation shouldn't overfit to that one format. Perhaps the
// copy_n32_from_history Wuffs method should also take an unroll hint
// limited_copy_u32_from_history Wuffs method should also take an unroll hint
// argument, and the cgen can look if that argument is the constant
// expression '3'.
//
// See also wuffs_base__io_writer__copy_n32_from_history_fast below.
// See also wuffs_base__io_writer__limited_copy_u32_from_history_fast below.
//
// Alternatively, or additionally, have a sloppy_copy_n32_from_history method
// that copies 8 bytes at a time, possibly writing more than length bytes?
// Alternatively or additionally, have a sloppy_limited_copy_u32_from_history
// method that copies 8 bytes at a time, which can more than length bytes?
for (; n >= 3; n -= 3) {
*p++ = *q++;
*p++ = *q++;
@@ -7780,18 +7780,18 @@ wuffs_base__io_writer__copy_n32_from_history(uint8_t** ptr_iop_w,
return length;
}
// wuffs_base__io_writer__copy_n32_from_history_fast is like the
// wuffs_base__io_writer__copy_n32_from_history function above, but has
// wuffs_base__io_writer__limited_copy_u32_from_history_fast is like the
// wuffs_base__io_writer__limited_copy_u32_from_history function above, but has
// stronger pre-conditions. The caller needs to prove that:
// - distance > 0
// - distance <= (*ptr_iop_w - io1_w)
// - length <= (io2_w - *ptr_iop_w)
static inline uint32_t //
wuffs_base__io_writer__copy_n32_from_history_fast(uint8_t** ptr_iop_w,
uint8_t* io1_w,
uint8_t* io2_w,
uint32_t length,
uint32_t distance) {
wuffs_base__io_writer__limited_copy_u32_from_history_fast(uint8_t** ptr_iop_w,
uint8_t* io1_w,
uint8_t* io2_w,
uint32_t length,
uint32_t distance) {
uint8_t* p = *ptr_iop_w;
uint8_t* q = p - distance;
uint32_t n = length;
@@ -7808,11 +7808,11 @@ wuffs_base__io_writer__copy_n32_from_history_fast(uint8_t** ptr_iop_w,
}
static inline uint32_t //
wuffs_base__io_writer__copy_n32_from_reader(uint8_t** ptr_iop_w,
uint8_t* io2_w,
uint32_t length,
const uint8_t** ptr_iop_r,
const uint8_t* io2_r) {
wuffs_base__io_writer__limited_copy_u32_from_reader(uint8_t** ptr_iop_w,
uint8_t* io2_w,
uint32_t length,
const uint8_t** ptr_iop_r,
const uint8_t* io2_r) {
uint8_t* iop_w = *ptr_iop_w;
size_t n = length;
if (n > ((size_t)(io2_w - iop_w))) {
@@ -7831,10 +7831,10 @@ wuffs_base__io_writer__copy_n32_from_reader(uint8_t** ptr_iop_w,
}
static inline uint32_t //
wuffs_base__io_writer__copy_n32_from_slice(uint8_t** ptr_iop_w,
uint8_t* io2_w,
uint32_t length,
wuffs_base__slice_u8 src) {
wuffs_base__io_writer__limited_copy_u32_from_slice(uint8_t** ptr_iop_w,
uint8_t* io2_w,
uint32_t length,
wuffs_base__slice_u8 src) {
uint8_t* iop_w = *ptr_iop_w;
size_t n = src.len;
if (n > length) {
@@ -15079,7 +15079,7 @@ wuffs_deflate__decoder__decode_uncompressed(wuffs_deflate__decoder* self,
}
v_length = ((v_length)&0xFFFF);
while (true) {
v_n_copied = wuffs_base__io_writer__copy_n32_from_reader(
v_n_copied = wuffs_base__io_writer__limited_copy_u32_from_reader(
&iop_a_dst, io2_a_dst, v_length, &iop_a_src, io2_a_src);
if (v_length <= v_n_copied) {
status = wuffs_base__make_status(NULL);
@@ -15948,7 +15948,7 @@ label__loop__continue:;
goto exit;
}
v_hdist = (self->private_impl.f_history_index - v_hdist);
wuffs_base__io_writer__copy_n32_from_slice(
wuffs_base__io_writer__limited_copy_u32_from_slice(
&iop_a_dst, io2_a_dst, v_hlen,
wuffs_base__slice_u8__subslice_i(
wuffs_base__make_slice_u8(self->private_data.f_history, 33025),
@@ -15963,7 +15963,7 @@ label__loop__continue:;
goto exit;
}
}
wuffs_base__io_writer__copy_n32_from_history_fast(
wuffs_base__io_writer__limited_copy_u32_from_history_fast(
&iop_a_dst, io0_a_dst, io2_a_dst, v_length, (v_dist_minus_1 + 1));
goto label__0__break;
}
@@ -16314,7 +16314,7 @@ wuffs_deflate__decoder__decode_huffman_slow(wuffs_deflate__decoder* self,
}
v_hdist = (self->private_impl.f_history_index - v_hdist);
while (true) {
v_n_copied = wuffs_base__io_writer__copy_n32_from_slice(
v_n_copied = wuffs_base__io_writer__limited_copy_u32_from_slice(
&iop_a_dst, io2_a_dst, v_hlen,
wuffs_base__slice_u8__subslice_ij(
wuffs_base__make_slice_u8(self->private_data.f_history,
@@ -16338,7 +16338,7 @@ wuffs_deflate__decoder__decode_huffman_slow(wuffs_deflate__decoder* self,
label__4__break:;
if (v_hlen > 0) {
while (true) {
v_n_copied = wuffs_base__io_writer__copy_n32_from_slice(
v_n_copied = wuffs_base__io_writer__limited_copy_u32_from_slice(
&iop_a_dst, io2_a_dst, v_hlen,
wuffs_base__slice_u8__subslice_ij(
wuffs_base__make_slice_u8(self->private_data.f_history,
@@ -16360,7 +16360,7 @@ wuffs_deflate__decoder__decode_huffman_slow(wuffs_deflate__decoder* self,
goto label__loop__continue;
}
}
v_n_copied = wuffs_base__io_writer__copy_n32_from_history(
v_n_copied = wuffs_base__io_writer__limited_copy_u32_from_history(
&iop_a_dst, io0_a_dst, io2_a_dst, v_length, (v_dist_minus_1 + 1));
if (v_length <= v_n_copied) {
v_length = 0;