go icon indicating copy to clipboard operation
go copied to clipboard

`ReadStringAsSlice` seems to copy the underlying slice.

Open jeschkies opened this issue 3 years ago • 0 comments

I may misunderstand the idea behind iter.ReadStringAsSlice. The documentation states:

ReadStringAsSlice read string from iterator without copying into string form. The []byte can not be kept, as it will change after next iterator call.

However, the bytes are actually copied if I'm not mistaken. So I'm wondering why can the returned []byte not be kept longer? Also, would it be possible to have a read without any copying and allocation which returned iter.buf[iter.head:iter.tail]?

jeschkies avatar Apr 20 '22 11:04 jeschkies