a cost, so it ought to be at least somewhat faster to make a slice as long
as I intend to use and then just fill in its contents directly by index.
That's what I default to if I know the length. But presently I have a
situation where I know the maximum length, say 100 items, but expect only
to use a fraction of that, say 30 items. So here's the questions.
Theoretically, what would be better, create an array with a capacity of
100, fill in what is needed, and slice off the rest, or create an empty
list and use append? Or in other terms, is the speed gained from not
having to grow the list worth the extra garbage created by specifying a
larger capacity than will actually be used? Hope that makes sense.
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.