From dcfdc02b77d45a5cdf12273fb6cb0227e5cc6e4c Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 14 Dec 2017 17:05:33 +0100 Subject: prog: minor refactoring around arguments Introduce isUsed(arg) helper, use it in several places. Move method definitions closer to their types. Simplify presence check for ArgUsed.Used() in several places. --- prog/encoding.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'prog/encoding.go') diff --git a/prog/encoding.go b/prog/encoding.go index 2b7999efc..7f0844dea 100644 --- a/prog/encoding.go +++ b/prog/encoding.go @@ -33,7 +33,7 @@ func (p *Prog) Serialize() []byte { vars := make(map[Arg]int) varSeq := 0 for _, c := range p.Calls { - if len(*c.Ret.(ArgUsed).Used()) != 0 { + if isUsed(c.Ret) { fmt.Fprintf(buf, "r%v = ", varSeq) vars[c.Ret] = varSeq varSeq++ @@ -58,7 +58,7 @@ func serialize(arg Arg, buf *bytes.Buffer, vars map[Arg]int, varSeq *int) { fmt.Fprintf(buf, "nil") return } - if used, ok := arg.(ArgUsed); ok && len(*used.Used()) != 0 { + if isUsed(arg) { fmt.Fprintf(buf, "", *varSeq) vars[arg] = *varSeq *varSeq++ -- cgit mrf-deployment