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/encodingexec.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'prog/encodingexec.go') diff --git a/prog/encodingexec.go b/prog/encodingexec.go index 937f3c322..c8855ebd6 100644 --- a/prog/encodingexec.go +++ b/prog/encodingexec.go @@ -94,8 +94,7 @@ func (p *Prog) SerializeForExec(buffer []byte, pid int) (int, error) { foreachArg(c, func(arg, _ Arg, _ *[]Arg) { if a, ok := arg.(*PointerArg); ok && a.Res != nil { foreachSubargOffset(a.Res, func(arg1 Arg, offset uint64) { - used, ok := arg1.(ArgUsed) - if (ok && len(*used.Used()) != 0) || csumUses[arg1] { + if isUsed(arg1) || csumUses[arg1] { w.args[arg1] = argInfo{Addr: p.Target.physicalAddr(arg) + offset} } if _, ok := arg1.(*GroupArg); ok { @@ -164,13 +163,13 @@ func (p *Prog) SerializeForExec(buffer []byte, pid int) (int, error) { for _, arg := range c.Args { w.writeArg(arg, pid, csumMap) } - if len(*c.Ret.(ArgUsed).Used()) != 0 { + if isUsed(c.Ret) { w.args[c.Ret] = argInfo{Idx: instrSeq} } instrSeq++ // Generate copyout instructions that persist interesting return values. foreachArg(c, func(arg, base Arg, _ *[]Arg) { - if used, ok := arg.(ArgUsed); !ok || len(*used.Used()) == 0 { + if !isUsed(arg) { return } switch arg.(type) { -- cgit mrf-deployment