On Tue, Sep 20, 2016, at 04:15 PM, Gabriel Adumitrachioaiei wrote:
> You might be right, but I just don't realize how. Since capacity will
> be 2x or 1.5x as before, reallocating the slice will not happen often.
> Or do you think that this would still be worse than copying almost all
> slice everytime there is a pop ?

I think it depends on your use case. For the sql package I suspect the
use case is a long running process with only a few members in the slice
and a roughly level number over time. In that case the cost of copying
will be small and offset by the savings in not needing to allocate.

However, if your use case is a a large slice that is iterated over via a
pop operation, with few or no pushes then it makes more sense to simply
reslice as you were doing in your original version.

Ian

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to