mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 00:52:18 +01:00
Place more vars at the top of functions
This commit is contained in:
1 parent
bac74a830d
commit
25776a724e
4 files changed
+38
-15
No files matched your search
@@ -4210,6 +4210,9 @@ wuffs_adler32__hasher__update(wuffs_adler32__hasher* self,
|
|||||||
uint32_t v_s2;
|
uint32_t v_s2;
|
||||||
wuffs_base__slice_u8 v_remaining;
|
wuffs_base__slice_u8 v_remaining;
|
||||||
|
|
||||||
|
v_s1 = 0;
|
||||||
|
v_s2 = 0;
|
||||||
|
v_remaining = ((wuffs_base__slice_u8){});
|
||||||
if (!self->private_impl.f_started) {
|
if (!self->private_impl.f_started) {
|
||||||
self->private_impl.f_started = true;
|
self->private_impl.f_started = true;
|
||||||
self->private_impl.f_state = 1;
|
self->private_impl.f_state = 1;
|
||||||
@@ -4217,7 +4220,7 @@ wuffs_adler32__hasher__update(wuffs_adler32__hasher* self,
|
|||||||
v_s1 = ((self->private_impl.f_state) & 0xFFFF);
|
v_s1 = ((self->private_impl.f_state) & 0xFFFF);
|
||||||
v_s2 = ((self->private_impl.f_state) >> (32 - (16)));
|
v_s2 = ((self->private_impl.f_state) >> (32 - (16)));
|
||||||
while (((uint64_t)(a_x.len)) > 0) {
|
while (((uint64_t)(a_x.len)) > 0) {
|
||||||
v_remaining = ((wuffs_base__slice_u8){});
|
v_remaining = wuffs_base__slice_u8__subslice_j(a_x, 0);
|
||||||
if (((uint64_t)(a_x.len)) > 5552) {
|
if (((uint64_t)(a_x.len)) > 5552) {
|
||||||
v_remaining = wuffs_base__slice_u8__subslice_i(a_x, 5552);
|
v_remaining = wuffs_base__slice_u8__subslice_i(a_x, 5552);
|
||||||
a_x = wuffs_base__slice_u8__subslice_j(a_x, 5552);
|
a_x = wuffs_base__slice_u8__subslice_j(a_x, 5552);
|
||||||
@@ -5049,6 +5052,7 @@ wuffs_crc32__ieee_hasher__update(wuffs_crc32__ieee_hasher* self,
|
|||||||
|
|
||||||
uint32_t v_s;
|
uint32_t v_s;
|
||||||
|
|
||||||
|
v_s = 0;
|
||||||
v_s = (4294967295 ^ self->private_impl.f_state);
|
v_s = (4294967295 ^ self->private_impl.f_state);
|
||||||
{
|
{
|
||||||
wuffs_base__slice_u8 i_slice_p = a_x;
|
wuffs_base__slice_u8 i_slice_p = a_x;
|
||||||
@@ -10012,6 +10016,14 @@ wuffs_gzip__decoder__decode(wuffs_gzip__decoder* self,
|
|||||||
switch (coro_susp_point) {
|
switch (coro_susp_point) {
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||||
|
|
||||||
|
v_c = 0;
|
||||||
|
v_flags = 0;
|
||||||
|
v_xlen = 0;
|
||||||
|
v_checksum_got = 0;
|
||||||
|
v_decoded_length_got = 0;
|
||||||
|
v_z = 0;
|
||||||
|
v_checksum_want = 0;
|
||||||
|
v_decoded_length_want = 0;
|
||||||
{
|
{
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io1_a_src)) {
|
if (WUFFS_BASE__UNLIKELY(iop_a_src == io1_a_src)) {
|
||||||
@@ -10164,8 +10176,6 @@ wuffs_gzip__decoder__decode(wuffs_gzip__decoder* self,
|
|||||||
status = wuffs_gzip__error__bad_encoding_flags;
|
status = wuffs_gzip__error__bad_encoding_flags;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
v_checksum_got = 0;
|
|
||||||
v_decoded_length_got = 0;
|
|
||||||
while (true) {
|
while (true) {
|
||||||
wuffs_base__io_writer__set_mark(&a_dst, iop_a_dst);
|
wuffs_base__io_writer__set_mark(&a_dst, iop_a_dst);
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,16 +22,20 @@ pub func hasher.update!(x slice base.u8) base.u32 {
|
|||||||
// The Adler-32 checksum's magic 65521 and 5552 numbers are discussed in
|
// The Adler-32 checksum's magic 65521 and 5552 numbers are discussed in
|
||||||
// RFC 1950.
|
// RFC 1950.
|
||||||
|
|
||||||
|
var s1 base.u32
|
||||||
|
var s2 base.u32
|
||||||
|
var remaining slice base.u8
|
||||||
|
|
||||||
if not this.started {
|
if not this.started {
|
||||||
this.started = true
|
this.started = true
|
||||||
this.state = 1
|
this.state = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
var s1 base.u32 = this.state.low_bits(n:16)
|
s1 = this.state.low_bits(n:16)
|
||||||
var s2 base.u32 = this.state.high_bits(n:16)
|
s2 = this.state.high_bits(n:16)
|
||||||
|
|
||||||
while args.x.length() > 0 {
|
while args.x.length() > 0 {
|
||||||
var remaining slice base.u8
|
remaining = args.x[:0]
|
||||||
if args.x.length() > 5552 {
|
if args.x.length() > 5552 {
|
||||||
remaining = args.x[5552:]
|
remaining = args.x[5552:]
|
||||||
args.x = args.x[:5552]
|
args.x = args.x[:5552]
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ pub struct ieee_hasher?(
|
|||||||
// to signal "initializer not called"? Should the return type, in the generated
|
// to signal "initializer not called"? Should the return type, in the generated
|
||||||
// C code, be "struct{ uint32_t checksum; wuffs_crc32__status status }"?
|
// C code, be "struct{ uint32_t checksum; wuffs_crc32__status status }"?
|
||||||
pub func ieee_hasher.update!(x slice base.u8) base.u32 {
|
pub func ieee_hasher.update!(x slice base.u8) base.u32 {
|
||||||
var s base.u32 = 0xFFFFFFFF ^ this.state
|
var s base.u32
|
||||||
|
|
||||||
|
s = 0xFFFFFFFF ^ this.state
|
||||||
|
|
||||||
// See "Multi-Byte Lookup Tables" in std/crc32/README.md for more detail on
|
// See "Multi-Byte Lookup Tables" in std/crc32/README.md for more detail on
|
||||||
// the slicing-by-M algorithm. We use an M of 16.
|
// the slicing-by-M algorithm. We use an M of 16.
|
||||||
|
|||||||
@@ -31,8 +31,17 @@ pub func decoder.set_ignore_checksum!(ic base.bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub func decoder.decode!??(dst base.io_writer, src base.io_reader) {
|
pub func decoder.decode!??(dst base.io_writer, src base.io_reader) {
|
||||||
|
var c base.u8
|
||||||
|
var flags base.u8
|
||||||
|
var xlen base.u16
|
||||||
|
var checksum_got base.u32
|
||||||
|
var decoded_length_got base.u32
|
||||||
|
var z base.status
|
||||||
|
var checksum_want base.u32
|
||||||
|
var decoded_length_want base.u32
|
||||||
|
|
||||||
// Read the header.
|
// Read the header.
|
||||||
var c base.u8 = args.src.read_u8!??()
|
c = args.src.read_u8!??()
|
||||||
if c != 0x1F {
|
if c != 0x1F {
|
||||||
return "?bad header"
|
return "?bad header"
|
||||||
}
|
}
|
||||||
@@ -44,13 +53,13 @@ pub func decoder.decode!??(dst base.io_writer, src base.io_reader) {
|
|||||||
if c != 0x08 {
|
if c != 0x08 {
|
||||||
return "?bad compression method"
|
return "?bad compression method"
|
||||||
}
|
}
|
||||||
var flags base.u8 = args.src.read_u8!??()
|
flags = args.src.read_u8!??()
|
||||||
// TODO: API for returning the header's MTIME field.
|
// TODO: API for returning the header's MTIME field.
|
||||||
args.src.skip!??(n:6)
|
args.src.skip!??(n:6)
|
||||||
|
|
||||||
// Handle FEXTRA.
|
// Handle FEXTRA.
|
||||||
if (flags & 0x04) != 0 {
|
if (flags & 0x04) != 0 {
|
||||||
var xlen base.u16 = args.src.read_u16le!??()
|
xlen = args.src.read_u16le!??()
|
||||||
args.src.skip!??(n:xlen as base.u32)
|
args.src.skip!??(n:xlen as base.u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,11 +98,9 @@ pub func decoder.decode!??(dst base.io_writer, src base.io_reader) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Decode and checksum the DEFLATE-encoded payload.
|
// Decode and checksum the DEFLATE-encoded payload.
|
||||||
var checksum_got base.u32
|
|
||||||
var decoded_length_got base.u32
|
|
||||||
while true {
|
while true {
|
||||||
args.dst.set_mark!()
|
args.dst.set_mark!()
|
||||||
var z base.status =? this.flate.decode!??(dst:args.dst, src:args.src)
|
z =? this.flate.decode!??(dst:args.dst, src:args.src)
|
||||||
if not this.ignore_checksum {
|
if not this.ignore_checksum {
|
||||||
checksum_got = this.checksum.update!(x:args.dst.since_mark())
|
checksum_got = this.checksum.update!(x:args.dst.since_mark())
|
||||||
decoded_length_got ~mod+= ((args.dst.since_mark().length() & 0xFFFFFFFF) as base.u32)
|
decoded_length_got ~mod+= ((args.dst.since_mark().length() & 0xFFFFFFFF) as base.u32)
|
||||||
@@ -103,8 +110,8 @@ pub func decoder.decode!??(dst base.io_writer, src base.io_reader) {
|
|||||||
}
|
}
|
||||||
yield z
|
yield z
|
||||||
}
|
}
|
||||||
var checksum_want base.u32 = args.src.read_u32le!??()
|
checksum_want = args.src.read_u32le!??()
|
||||||
var decoded_length_want base.u32 = args.src.read_u32le!??()
|
decoded_length_want = args.src.read_u32le!??()
|
||||||
if (not this.ignore_checksum) and
|
if (not this.ignore_checksum) and
|
||||||
((checksum_got != checksum_want) or (decoded_length_got != decoded_length_want)) {
|
((checksum_got != checksum_want) or (decoded_length_got != decoded_length_want)) {
|
||||||
return "?bad checksum"
|
return "?bad checksum"
|
||||||
|
|||||||
Reference in new issue
Block a user