|| at Dec 4, 2012 at 5:46 am
On Monday, December 3, 2012 11:29:39 PM UTC-6, Erik Aigner wrote:
No I'm not asking to copy without copying, I'm asking how to append
but if append() already does that, than that's what I was looking for.
I just wasn't sure what the builtin append() exactly does underneath (if
it allocates memory)
Well if it *needs* to allocate new memory to append it does, which I have
always assumed does a full copy.
len := 10
cap := 20 // capacity
x := make(byte, len, cap)
you can append 10 bytes onto that without it doing an alloc.
but if you never do it has 10 unused bytes...
Slices have a backing array. You could try a linked list or other data
structure if the copying is slowing down your program.