[go-nuts] Re: readonly []byte required

2019-07-05 Thread Ugorji Nwoke
This came up about 5 or so years ago. Brad proposed it, it was deliberated for a while, and Russ articulated why it was no doable at the time. There may be a chance to resurrect it, but it will be good to see what was written before. See Prior discussion:

Re: [go-nuts] Re: readonly []byte required

2019-07-05 Thread Robert Engels
In the case of high performance IO, where probably most strings are converted, you use a ByteBuffer to avoid many small kernel calls anyway, and these can copy the string data (WriteString) to the buffer directly without an intermediate allocation. > On Jul 5, 2019, at 7:00 AM, Slawomir

[go-nuts] Re: readonly []byte required

2019-07-05 Thread Slawomir Pryczek
Not sure if that's a good idea. Strings are immutable so you can pass string to function by reference, in thread safe manner. So if you pass same string to 2 threads and one of them modify it - you'll really have allocate+copy+modify so you're never touching the original thing so you can't

[go-nuts] Re: readonly []byte required

2019-07-05 Thread Max
I think it could be a useful optimization. There are at least in two different (and much more general) proposals that, if accepted, would include readonly slices as a special case. The the compiler could recognize that a readonly slice created from a string can reuse string's underlying data: