Hello Ian,

Thank you for your answer.

On Sun, 05/26/19, May 26, 2019 at 07:59:07PM -0400, Ian Lance Taylor wrote:
> This is not valid.  The rule is that SliceHeader is only valid when
> inspecting an actual slice header.  You have to write
> 
>     h.Data = uintptr(unsafe.Pointer(&b))
>     h.Len = len(b)
>     h.Cap = len(b)
> 
> I assume this is reduced greatly from the real code, as you could also
> just write
> 
>     bts = b[:]

Does this mean that it is not possible to get rid of heap allocation for
passing slice of bytes to some method interface like io.Reader.Read()?

Both code examples above are leading b to escape to the heap when
passing to the interface method.

-- 
Regards,
Sergey.

-- 
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/20190527061838.GA8345%40MacBook-Pro-Sergej.local.
For more options, visit https://groups.google.com/d/optout.

Reply via email to