From 4f4f70406cad6adf80c2bf8fb5b6b9049f2984d0 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 17 Feb 2018 17:29:23 +0100 Subject: prog: unexport Args and PyPhysicalAddr --- prog/encodingexec.go | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) (limited to 'prog/encodingexec.go') diff --git a/prog/encodingexec.go b/prog/encodingexec.go index d81873b33..1d5b5e870 100644 --- a/prog/encodingexec.go +++ b/prog/encodingexec.go @@ -51,25 +51,6 @@ const ( ExecNoCopyout = ^uint64(0) ) -type Args []Arg - -func (s Args) Len() int { - return len(s) -} - -func (s Args) Swap(i, j int) { - s[i], s[j] = s[j], s[i] -} - -type ByPhysicalAddr struct { - Args - Context *execContext -} - -func (s ByPhysicalAddr) Less(i, j int) bool { - return s.Context.args[s.Args[i]].Addr < s.Context.args[s.Args[j]].Addr -} - // SerializeForExec serializes program p for execution by process pid into the provided buffer. // Returns number of bytes written to the buffer. // If the provided buffer is too small for the program an error is returned. @@ -137,7 +118,9 @@ func (p *Prog) SerializeForExec(buffer []byte) (int, error) { for arg := range csumMap { csumArgs = append(csumArgs, arg) } - sort.Sort(ByPhysicalAddr{Args: csumArgs, Context: w}) + sort.Slice(csumArgs, func(i, j int) bool { + return w.args[csumArgs[i]].Addr < w.args[csumArgs[j]].Addr + }) for i := len(csumArgs) - 1; i >= 0; i-- { arg := csumArgs[i] if _, ok := arg.Type().(*CsumType); !ok { -- cgit mrf-deployment