3 ms·
I've never heard of a good argument for this as compared to a capacity, length, and data struct. If you have a start and end pointer and you move either one, y
by andrewmcwatters 4y ago
I've never heard of a good argument for this as compared to a capacity, length, and data struct.
If you have a start and end pointer and you move either one, you don't know what the original size of the allocation was.
- KingLancelot 4y ago[dead]
- ntrel 4y agoD doesn't store capacity in each slice. This allows a slice to fit in registers more often. Instead for GC allocated slices, the GC will store metadata before the first element of the allocation. That does make it slower to access, particularly when the slice points past the first element, but it is cached to speed up repeated accesses to the same allocation. Repeated appending can be further speeded up by using a dedicated Appender type.