On Thursday, August 4, 2016 at 12:40:41 AM UTC+8, Hotei wrote:
>
> Looking at the asm it appears that there is a conversion func called in 
> the second version - right before the copy with memmove.
>
> Based on this I'd say what happens AFTER the conversion is the same in 
> both version since the destination is the same and the content is the same. 
>  The only optimization I see is  not doing an unnecessary explicit 
> conversion.  I'm not sure this helps.  Am I answering the right question?  
>

I am still not clear about your answer, yes or not?
 

>
> On Wednesday, August 3, 2016 at 11:27:36 AM UTC-4, T L wrote:
>>
>>
>> I know a string value can be used as []byte if the first parameter if the 
>> builtin copy/append function is a []byte value:
>>
>>> var bs []byte = make([]byte, 10)
>>> copy(bs, "abcde")
>>
>>
>> but if do explicit conversion anyway on the second string value  
>>
>>> var bs []byte = make([]byte, 10)
>>> copy(bs, []byte("abcde"))
>>>
>> will compiler do optimization here to avoid copying the underline byte 
>> array of the string? 
>>
>>

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