Closed dgryski closed 3 months ago
If the capacity of s is not large enough to fit the additional values, append [allocates](https://go.dev/ref/spec#Allocation) a new, sufficiently large underlying array that fits both the existing slice elements and the additional values. Otherwise, append re-uses the underlying array.
I think the word "new" there certainly implies we can't realloc()
, and the the three-form slice notation was added to allow people to append to a slice and know that it would be a copy that was returned. Oh well, back to the drawing board...
Hmm. Good point. I was looking at this for an optimization where the caller is doing a lot of appends. I'll check the spec and see if we have any wiggle room.