diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-12-14 17:05:33 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-12-17 11:39:14 +0100 |
| commit | dcfdc02b77d45a5cdf12273fb6cb0227e5cc6e4c (patch) | |
| tree | 3c8057bd67b947ccdaf6c9d239cdf68b4c7304be /prog/encoding.go | |
| parent | 9c21f3116fc2059a66c2cff309a303933daf8934 (diff) | |
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.
Diffstat (limited to 'prog/encoding.go')
| -rw-r--r-- | prog/encoding.go | 4 |
1 files changed, 2 insertions, 2 deletions
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, "<r%v=>", *varSeq) vars[arg] = *varSeq *varSeq++ |
