diff options
Diffstat (limited to 'src/cmd/internal/obj/bootstrap.go')
| -rw-r--r-- | src/cmd/internal/obj/bootstrap.go | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/src/cmd/internal/obj/bootstrap.go b/src/cmd/internal/obj/bootstrap.go deleted file mode 100644 index 42835e1d9d..0000000000 --- a/src/cmd/internal/obj/bootstrap.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.8 - -package obj - -import ( - "reflect" - "sort" -) - -func SortSlice(slice interface{}, less func(i, j int) bool) { - val := reflect.ValueOf(slice) - tmp := reflect.New(val.Type().Elem()).Elem() - x := sliceByFn{val: val, tmp: tmp, less: less} - sort.Sort(x) -} - -type sliceByFn struct { - val reflect.Value - tmp reflect.Value - less func(i, j int) bool -} - -func (x sliceByFn) Len() int { return x.val.Len() } -func (x sliceByFn) Less(i, j int) bool { return x.less(i, j) } -func (x sliceByFn) Swap(i, j int) { - a, b := x.val.Index(i), x.val.Index(j) - x.tmp.Set(a) - a.Set(b) - b.Set(x.tmp) -} |
