Change iterate variable types from ptr to slice

This commit is contained in:
Nigel Tao committed 2018-05-04 13:20:34 +10:00
1 parent d85a94360e
commit 96a549814d
8 files changed
+54 -52

No files matched your search

+23 -21
View File
@@ -1663,39 +1663,41 @@ uint32_t wuffs_adler32__hasher__update(wuffs_adler32__hasher* self,
}
{
wuffs_base__slice_u8 i_slice_p = a_x;
uint8_t* v_p = i_slice_p.ptr;
wuffs_base__slice_u8 v_p = i_slice_p;
v_p.len = 1;
uint8_t* i_end0_p = i_slice_p.ptr + (i_slice_p.len / 8) * 8;
while (v_p < i_end0_p) {
v_s1 += ((uint32_t)(v_p[0]));
while (v_p.ptr < i_end0_p) {
v_s1 += ((uint32_t)(v_p.ptr[0]));
v_s2 += v_s1;
v_p += 1;
v_s1 += ((uint32_t)(v_p[0]));
v_p.ptr += 1;
v_s1 += ((uint32_t)(v_p.ptr[0]));
v_s2 += v_s1;
v_p += 1;
v_s1 += ((uint32_t)(v_p[0]));
v_p.ptr += 1;
v_s1 += ((uint32_t)(v_p.ptr[0]));
v_s2 += v_s1;
v_p += 1;
v_s1 += ((uint32_t)(v_p[0]));
v_p.ptr += 1;
v_s1 += ((uint32_t)(v_p.ptr[0]));
v_s2 += v_s1;
v_p += 1;
v_s1 += ((uint32_t)(v_p[0]));
v_p.ptr += 1;
v_s1 += ((uint32_t)(v_p.ptr[0]));
v_s2 += v_s1;
v_p += 1;
v_s1 += ((uint32_t)(v_p[0]));
v_p.ptr += 1;
v_s1 += ((uint32_t)(v_p.ptr[0]));
v_s2 += v_s1;
v_p += 1;
v_s1 += ((uint32_t)(v_p[0]));
v_p.ptr += 1;
v_s1 += ((uint32_t)(v_p.ptr[0]));
v_s2 += v_s1;
v_p += 1;
v_s1 += ((uint32_t)(v_p[0]));
v_p.ptr += 1;
v_s1 += ((uint32_t)(v_p.ptr[0]));
v_s2 += v_s1;
v_p += 1;
v_p.ptr += 1;
}
v_p.len = 1;
uint8_t* i_end1_p = i_slice_p.ptr + i_slice_p.len;
while (v_p < i_end1_p) {
v_s1 += ((uint32_t)(v_p[0]));
while (v_p.ptr < i_end1_p) {
v_s1 += ((uint32_t)(v_p.ptr[0]));
v_s2 += v_s1;
v_p++;
v_p.ptr++;
}
}
v_s1 %= 65521;
+15 -12
View File
@@ -2015,26 +2015,29 @@ uint32_t wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self,
v_s = (4294967295 ^ self->private_impl.f_state);
{
wuffs_base__slice_u8 i_slice_p = a_x;
uint8_t* v_p = i_slice_p.ptr;
wuffs_base__slice_u8 v_p = i_slice_p;
v_p.len = 8;
uint8_t* i_end0_p = i_slice_p.ptr + (i_slice_p.len / 8) * 8;
while (v_p < i_end0_p) {
v_s ^= ((((uint32_t)(v_p[0])) << 0) | (((uint32_t)(v_p[1])) << 8) |
(((uint32_t)(v_p[2])) << 16) | (((uint32_t)(v_p[3])) << 24));
v_s = (wuffs_crc32__ieee_table[0][v_p[7]] ^
wuffs_crc32__ieee_table[1][v_p[6]] ^
wuffs_crc32__ieee_table[2][v_p[5]] ^
wuffs_crc32__ieee_table[3][v_p[4]] ^
while (v_p.ptr < i_end0_p) {
v_s ^=
((((uint32_t)(v_p.ptr[0])) << 0) | (((uint32_t)(v_p.ptr[1])) << 8) |
(((uint32_t)(v_p.ptr[2])) << 16) | (((uint32_t)(v_p.ptr[3])) << 24));
v_s = (wuffs_crc32__ieee_table[0][v_p.ptr[7]] ^
wuffs_crc32__ieee_table[1][v_p.ptr[6]] ^
wuffs_crc32__ieee_table[2][v_p.ptr[5]] ^
wuffs_crc32__ieee_table[3][v_p.ptr[4]] ^
wuffs_crc32__ieee_table[4][255 & (v_s >> 24)] ^
wuffs_crc32__ieee_table[5][255 & (v_s >> 16)] ^
wuffs_crc32__ieee_table[6][255 & (v_s >> 8)] ^
wuffs_crc32__ieee_table[7][255 & (v_s >> 0)]);
v_p += 8;
v_p.ptr += 8;
}
v_p.len = 1;
uint8_t* i_end1_p = i_slice_p.ptr + i_slice_p.len;
while (v_p < i_end1_p) {
v_s = (wuffs_crc32__ieee_table[0][((uint8_t)((v_s & 255))) ^ v_p[0]] ^
while (v_p.ptr < i_end1_p) {
v_s = (wuffs_crc32__ieee_table[0][((uint8_t)((v_s & 255))) ^ v_p.ptr[0]] ^
(v_s >> 8));
v_p++;
v_p.ptr++;
}
}
self->private_impl.f_state = (4294967295 ^ v_s);