On Wed, May 3, 2017 at 6:39 PM Piotr Narewski <piotr...@gmail.com> wrote:

> I am supposed to allocate the slice with "slice.Bytes.Get(515).(*[]byte)"
not "make([]byte, 515)"

Yes. Even better is

        p := slice.Bytes.Get(n)
        b := *p
        ... use b as usual, it's already a []byte.
        slice.Bytes.Put(p)

This way the slice header will not be allocated again (out of the pool).



-- 

-j

-- 
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