mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +00:00
Updated SliceTricks (markdown)
parent
404f1a2952
commit
ee9fc72909
@ -106,10 +106,10 @@ s[i] = x
|
|||||||
a = append(a[:i], append(b, a[i:]...)...)
|
a = append(a[:i], append(b, a[i:]...)...)
|
||||||
|
|
||||||
// The above one-line way copies a[i:] twice and
|
// The above one-line way copies a[i:] twice and
|
||||||
// might allocate at most twice.
|
// allocates at least once.
|
||||||
// The following verbose way only allocates at
|
// The following verbose way only copy elements
|
||||||
// most once and copy elements in a[i:] once.
|
// in a[i:] once and allocates at most once.
|
||||||
// But as of Go toolchain 1.16, due to lacking of
|
// But, as of Go toolchain 1.16, due to lacking of
|
||||||
// optimizations to avoid elements clearing in the
|
// optimizations to avoid elements clearing in the
|
||||||
// "make" call, the verbose way is not always faster.
|
// "make" call, the verbose way is not always faster.
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user