On Mon, Jul 11, 2016 at 4:40 PM, Erich Rickheit KSC
wrote:
> Ian Lance Taylor wrote:
>> On Sat, Jul 9, 2016 at 4:38 PM, Erich Rickheit KSC
>> wrote:
>> > I found myself writing code like this:
>> >
>> > s := make([]byte, len)
>> > for i := 0; i < len; i++ {
>> > /
On Mon, Jul 11, 2016 at 5:41 PM Erich Rickheit KSC
wrote:
> Ian Lance Taylor wrote:
> > On Sat, Jul 9, 2016 at 4:38 PM, Erich Rickheit KSC
> wrote:
> > > I found myself writing code like this:
> > >
> > > s := make([]byte, len)
> > > for i := 0; i < len; i++ {
> > >
Ian Lance Taylor wrote:
> On Sat, Jul 9, 2016 at 4:38 PM, Erich Rickheit KSC
> wrote:
> > I found myself writing code like this:
> >
> > s := make([]byte, len)
> > for i := 0; i < len; i++ {
> > // fill in s with stringy goodness
> > }
> > return st
There are places throughout the standard packages where extra copies happen
due to []byte <-> string conversion (like strings.Join(),
os.*File.WriteString() etc.) I am assuming they don't use an unsafe-magic
way to make aliasing strings and []bytes because they don't want people to
shoot them
On Mon, Jul 11, 2016 at 3:28 PM, Ian Lance Taylor wrote:
> On Mon, Jul 11, 2016 at 3:49 AM, Manlio Perillo
> wrote:
>> Il giorno domenica 10 luglio 2016 04:51:21 UTC+2, Ian Lance Taylor ha
>> scritto:
>>>
>>> On Sat, Jul 9, 2016 at 4:38 PM, Erich Rickheit KSC
>>> wrote:
>>> > I found myself writ
On Mon, Jul 11, 2016 at 3:49 AM, Manlio Perillo
wrote:
> Il giorno domenica 10 luglio 2016 04:51:21 UTC+2, Ian Lance Taylor ha
> scritto:
>>
>> On Sat, Jul 9, 2016 at 4:38 PM, Erich Rickheit KSC
>> wrote:
>> > I found myself writing code like this:
>> >
>> > s := make([]byte, len)
>> >
Il giorno domenica 10 luglio 2016 04:51:21 UTC+2, Ian Lance Taylor ha
scritto:
>
> On Sat, Jul 9, 2016 at 4:38 PM, Erich Rickheit KSC > wrote:
> > I found myself writing code like this:
> >
> > s := make([]byte, len)
> > for i := 0; i < len; i++ {
> > // fill
On Sat, Jul 9, 2016 at 4:38 PM, Erich Rickheit KSC wrote:
> I found myself writing code like this:
>
> s := make([]byte, len)
> for i := 0; i < len; i++ {
> // fill in s with stringy goodness
> }
> return string(s)
>
> Does this reuse the memory in s
I found myself writing code like this:
s := make([]byte, len)
for i := 0; i < len; i++ {
// fill in s with stringy goodness
}
return string(s)
Does this reuse the memory in s for the string, or does it allocate new
memory and copy? Or does escape an