From 10042f7dbcf02df5cad5fb3d3fc24aad0458ab4f Mon Sep 17 00:00:00 2001 From: Go101 <22589241+go101@users.noreply.github.com> Date: Sun, 9 May 2021 12:12:02 -0400 Subject: [PATCH] Updated SliceTricks (markdown) --- SliceTricks.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SliceTricks.md b/SliceTricks.md index 78dea5fc..78edbbb9 100644 --- a/SliceTricks.md +++ b/SliceTricks.md @@ -17,6 +17,11 @@ copy(b, a) // elements to be appended to b after copying. b = append([]T(nil), a...) b = append(a[:0:0], a...) + +// This one-line implementation is equivalent to the above +// tow-line make+copy implementation. But it is actually +// a bit slower (as of Go toolchain v1.16). +b = append(make([]T, 0, len(a)), a...) ``` #### Cut