helper/schema: remove swap tracking
This commit is contained in:
parent
312acf3e40
commit
a7e1154a0f
|
@ -4,7 +4,6 @@ package schema
|
|||
// to a schema.
|
||||
type listSort struct {
|
||||
List []interface{}
|
||||
Map map[int]int
|
||||
Schema *Schema
|
||||
}
|
||||
|
||||
|
@ -18,19 +17,4 @@ func (s *listSort) Less(i, j int) bool {
|
|||
|
||||
func (s *listSort) Swap(i, j int) {
|
||||
s.List[i], s.List[j] = s.List[j], s.List[i]
|
||||
|
||||
// Build the mapping. We have to make sure we get to the proper
|
||||
// place where the final target is, not the current value.
|
||||
if s.Map == nil {
|
||||
s.Map = make(map[int]int)
|
||||
}
|
||||
i2 := i
|
||||
j2 := j
|
||||
if v, ok := s.Map[i]; ok {
|
||||
i2 = v
|
||||
}
|
||||
if v, ok := s.Map[j]; ok {
|
||||
j2 = v
|
||||
}
|
||||
s.Map[i], s.Map[j] = j2, i2
|
||||
}
|
||||
|
|
|
@ -26,15 +26,4 @@ func TestListSort(t *testing.T) {
|
|||
if !reflect.DeepEqual(s.List, expected) {
|
||||
t.Fatalf("bad: %#v", s.List)
|
||||
}
|
||||
|
||||
expectedMap := map[int]int{
|
||||
0: 2,
|
||||
1: 1,
|
||||
2: 3,
|
||||
3: 4,
|
||||
4: 0,
|
||||
}
|
||||
if !reflect.DeepEqual(s.Map, expectedMap) {
|
||||
t.Fatalf("bad: %#v", s.Map)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue