aboutsummaryrefslogtreecommitdiffstats
path: root/prog/encoding.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-05-05 10:25:45 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-05-05 10:25:45 +0200
commitafe402d20af0d54d4e0baeb9e70e668e2a26f188 (patch)
tree58f79c51ee9c8a48939059a23c47d68751d55701 /prog/encoding.go
parent9dfb5efa91fc0f051a1ddc88ace2867bb6b32275 (diff)
prog: make c.Ret optional
No reason to allocate return value if there is no return type. c.Ret == nil is the reasonable indication that this is a "void" call.
Diffstat (limited to 'prog/encoding.go')
-rw-r--r--prog/encoding.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/prog/encoding.go b/prog/encoding.go
index 86577cd12..f0d96da95 100644
--- a/prog/encoding.go
+++ b/prog/encoding.go
@@ -33,7 +33,7 @@ func (p *Prog) Serialize() []byte {
vars := make(map[*ResultArg]int)
varSeq := 0
for _, c := range p.Calls {
- if len(c.Ret.uses) != 0 {
+ if c.Ret != nil && len(c.Ret.uses) != 0 {
fmt.Fprintf(buf, "r%v = ", varSeq)
vars[c.Ret] = varSeq
varSeq++
@@ -206,7 +206,7 @@ func (target *Target) Deserialize(data []byte) (prog *Prog, err error) {
if len(c.Args) != len(meta.Args) {
return nil, fmt.Errorf("wrong call arg count: %v, want %v", len(c.Args), len(meta.Args))
}
- if r != "" {
+ if r != "" && c.Ret != nil {
vars[r] = c.Ret
}
}