mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
As the examples are about performance, perform the mininal work required
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]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user