If you use make(type, len, capacity), then it would only reallocate if your estimated size was under the actual size.
Also I believe that re-slicing would still use the same underlying array, so it would set the length but still keep the capacity.
You’d have to create a new slice of actual capacity and copy to it.
If you use make(type, len, capacity), then it would only reallocate if your estimated size was under the actual size.
Also I believe that re-slicing would still use the same underlying array, so it would set the length but still keep the capacity.
You’d have to create a new slice of actual capacity and copy to it.