Ah I see.  In particular, if you have a slice whose len and cap are both 
1000, the new cap is 2048; but if you have a slice whose len and cap are 
both 1100, then the new cap is 1408.

I don't see that as a problem in any shape or form.  All that's required is:
(1) New cap is at least as large as new required len
(2) Some extra slack on cap to allow for some future growth.  Even that 
requirement is a heuristic, on the grounds that "if you've already appended 
to a slice at least once, then you're likely to append to it again" (but 
you may not).

I agree with what's been said already.  If the OP wants to propose and 
implement a specific new heuristic, and can prove via benchmarking that it 
doesn't degrade performance overall, then let them do so.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/35c4ae93-7415-4313-a33e-3b85f99dc42fn%40googlegroups.com.

Reply via email to