mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-20 00:47:28 +01:00
Add choose
wuffs_png_decode_filter_1_sub/clang9 905MB/s ± 0% 1339MB/s ± 0% +48.05% (p=0.008 n=5+5) wuffs_png_decode_filter_1_sub/gcc10 1.12GB/s ± 0% 1.85GB/s ± 0% +64.80% (p=0.016 n=5+4)
This commit is contained in:
1 parent
364c396ae8
commit
beaf3ef11f
11 files changed
+235
-22
No files matched your search
@@ -57,6 +57,8 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
|
||||
case a.KAssign:
|
||||
n := n.AsAssign()
|
||||
return g.writeStatementAssign(b, n.Operator(), n.LHS(), n.RHS(), depth)
|
||||
case a.KChoose:
|
||||
return g.writeStatementChoose(b, n.AsChoose(), depth)
|
||||
case a.KIOBind:
|
||||
return g.writeStatementIOBind(b, n.AsIOBind(), depth)
|
||||
case a.KIf:
|
||||
@@ -221,6 +223,22 @@ func (g *gen) writeStatementAssign1(b *buffer, op t.ID, lhs *a.Expr, rhs *a.Expr
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *gen) writeStatementChoose(b *buffer, n *a.Choose, depth uint32) error {
|
||||
recv := g.currFunk.astFunc.Receiver()
|
||||
args := n.Args()
|
||||
if len(args) != 1 {
|
||||
return fmt.Errorf("TODO: multiple choice")
|
||||
}
|
||||
id := args[0].AsExpr().Ident()
|
||||
suffix := ""
|
||||
if n.Name() == id {
|
||||
suffix = "__choosy_default"
|
||||
}
|
||||
b.printf("self->private_impl.choosy_%s = &%s%s__%s%s;\n",
|
||||
n.Name().Str(g.tm), g.pkgPrefix, recv.Str(g.tm), id.Str(g.tm), suffix)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *gen) writeStatementIOBind(b *buffer, n *a.IOBind, depth uint32) error {
|
||||
if g.currFunk.ioBinds > maxIOBinds {
|
||||
return fmt.Errorf("too many temporary variables required")
|
||||
|
||||
Reference in new issue
Block a user