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)
3333// * Drivers are supposed to be read only.
3434// * Ideally don't load any contents (into memory) in Open or WithInstance.
3535type Driver interface {
36- // Open returns a a new driver instance configured with parameters
36+ // Open returns a new driver instance configured with parameters
3737 // coming from the URL string. Migrate will call this function
3838 // only once per instance.
3939 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) {
6666}
6767
6868func (i * Migrations ) buildIndex () {
69- i .index = make (uintSlice , 0 )
69+ i .index = make (uintSlice , 0 , len ( i . migrations ) )
7070 for version := range i .migrations {
7171 i .index = append (i .index , version )
7272 }
73- sort .Sort (i .index )
73+ sort .Slice (i .index , func (x , y int ) bool {
74+ return i .index [x ] < i .index [y ]
75+ })
7476}
7577
7678func (i * Migrations ) First () (version uint , ok bool ) {
@@ -126,18 +128,6 @@ func (i *Migrations) findPos(version uint) int {
126128
127129type uintSlice []uint
128130
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-
141131func (s uintSlice ) Search (x uint ) int {
142132 return sort .Search (len (s ), func (i int ) bool { return s [i ] >= x })
143133}
You can’t perform that action at this time.
0 commit comments