aboutsummaryrefslogtreecommitdiffstats
path: root/prog/encodingexec.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-02-17 17:29:23 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-02-17 19:02:12 +0100
commit4f4f70406cad6adf80c2bf8fb5b6b9049f2984d0 (patch)
treecb8292cac0b95c5e368b56a183535da184763f81 /prog/encodingexec.go
parent32aa64c5acbc82b6f4f3605ccfdf3b62faf9a094 (diff)
prog: unexport Args and PyPhysicalAddr
Diffstat (limited to 'prog/encodingexec.go')
-rw-r--r--prog/encodingexec.go23
1 files changed, 3 insertions, 20 deletions
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 {