File tree Expand file tree Collapse file tree 2 files changed +5
-15
lines changed Expand file tree Collapse file tree 2 files changed +5
-15
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ var drivers = make(map[string]Driver)
33
33
// * Drivers are supposed to be read only.
34
34
// * Ideally don't load any contents (into memory) in Open or WithInstance.
35
35
type Driver interface {
36
- // Open returns a a new driver instance configured with parameters
36
+ // Open returns a new driver instance configured with parameters
37
37
// coming from the URL string. Migrate will call this function
38
38
// only once per instance.
39
39
Open (url string ) (Driver , error )
Original file line number Diff line number Diff line change @@ -66,11 +66,13 @@ func (i *Migrations) Append(m *Migration) (ok bool) {
66
66
}
67
67
68
68
func (i * Migrations ) buildIndex () {
69
- i .index = make (uintSlice , 0 )
69
+ i .index = make (uintSlice , 0 , len ( i . migrations ) )
70
70
for version := range i .migrations {
71
71
i .index = append (i .index , version )
72
72
}
73
- sort .Sort (i .index )
73
+ sort .Slice (i .index , func (x , y int ) bool {
74
+ return i .index [x ] < i .index [y ]
75
+ })
74
76
}
75
77
76
78
func (i * Migrations ) First () (version uint , ok bool ) {
@@ -126,18 +128,6 @@ func (i *Migrations) findPos(version uint) int {
126
128
127
129
type uintSlice []uint
128
130
129
- func (s uintSlice ) Len () int {
130
- return len (s )
131
- }
132
-
133
- func (s uintSlice ) Swap (i , j int ) {
134
- s [i ], s [j ] = s [j ], s [i ]
135
- }
136
-
137
- func (s uintSlice ) Less (i , j int ) bool {
138
- return s [i ] < s [j ]
139
- }
140
-
141
131
func (s uintSlice ) Search (x uint ) int {
142
132
return sort .Search (len (s ), func (i int ) bool { return s [i ] >= x })
143
133
}
You can’t perform that action at this time.
0 commit comments