Simplify temporary io_bind variables

This commit is contained in:
Nigel Tao committed 2018-05-13 10:52:49 +10:00
1 parent 92720594ac
commit a86023b290
2 files changed
+12 -17

No files matched your search

+8 -9
View File
@@ -169,12 +169,13 @@ func (g *gen) writeStatementIOBind(b *buffer, n *a.IOBind, depth uint32) error {
if e.Operator() != 0 { if e.Operator() != 0 {
prefix = aPrefix prefix = aPrefix
} }
name := e.Ident().Str(g.tm) cTyp := "reader"
// TODO: stash the whole io_reader, not just its bounds. if e.MType().QID()[1] == t.IDIOWriter {
for j := 0; j < 2; j++ { cTyp = "writer"
b.printf("uint8_t* %s%d_bounds%d_%s%s = %s%s.private_impl.bounds[%d];\n",
oPrefix, ioBindNum, j, prefix, name, prefix, name, j)
} }
name := e.Ident().Str(g.tm)
b.printf("wuffs_base__io_%s %s%d_%s%s = %s%s;\n",
cTyp, oPrefix, ioBindNum, prefix, name, prefix, name)
} }
for _, o := range n.Body() { for _, o := range n.Body() {
@@ -190,10 +191,8 @@ func (g *gen) writeStatementIOBind(b *buffer, n *a.IOBind, depth uint32) error {
prefix = aPrefix prefix = aPrefix
} }
name := e.Ident().Str(g.tm) name := e.Ident().Str(g.tm)
for j := 1; j >= 0; j-- { b.printf("%s%s = %s%d_%s%s;\n",
b.printf("%s%s.private_impl.bounds[%d] = %s%d_bounds%d_%s%s;\n", prefix, name, oPrefix, ioBindNum, prefix, name)
prefix, name, j, oPrefix, ioBindNum, j, prefix, name)
}
} }
b.writes("}\n") b.writes("}\n")
return nil return nil
+4 -8
View File
@@ -2878,10 +2878,8 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id(
while (true) { while (true) {
v_w = ((wuffs_base__io_writer){}); v_w = ((wuffs_base__io_writer){});
{ {
uint8_t* o_0_bounds0_a_src = a_src.private_impl.bounds[0]; wuffs_base__io_reader o_0_a_src = a_src;
uint8_t* o_0_bounds1_a_src = a_src.private_impl.bounds[1]; wuffs_base__io_writer o_0_v_w = v_w;
uint8_t* o_0_bounds0_v_w = v_w.private_impl.bounds[0];
uint8_t* o_0_bounds1_v_w = v_w.private_impl.bounds[1];
wuffs_base__io_reader__set_limit(&a_src, b_rptr_src, v_block_size); wuffs_base__io_reader__set_limit(&a_src, b_rptr_src, v_block_size);
wuffs_base__io_reader__set_mark(&a_src, b_rptr_src); wuffs_base__io_reader__set_mark(&a_src, b_rptr_src);
{ {
@@ -2905,10 +2903,8 @@ static wuffs_gif__status wuffs_gif__decoder__decode_id(
a_src.private_impl.bounds[0]), a_src.private_impl.bounds[0]),
}) })
.len))); .len)));
v_w.private_impl.bounds[1] = o_0_bounds1_v_w; v_w = o_0_v_w;
v_w.private_impl.bounds[0] = o_0_bounds0_v_w; a_src = o_0_a_src;
a_src.private_impl.bounds[1] = o_0_bounds1_a_src;
a_src.private_impl.bounds[0] = o_0_bounds0_a_src;
} }
if (v_z == 0) { if (v_z == 0) {
self->private_impl.f_previous_lzw_decode_ended_abruptly = false; self->private_impl.f_previous_lzw_decode_ended_abruptly = false;