As the examples are about performance, perform the mininal work required

Thomas Mangin 2018-12-31 17:41:42 +00:00
parent 3941028dc4
commit bc97e754b5

@ -182,7 +182,10 @@ for i := 1; i < len(in); i++ {
continue continue
} }
j++ j++
in[i], in[j] = in[j], in[i] // preserve the original data
// in[i], in[j] = in[j], in[i]
// only set what is required
in[j] = in[i]
} }
result := in[:j+1] result := in[:j+1]
fmt.Println(result) // [1 2 3 4] fmt.Println(result) // [1 2 3 4]