I surely will use the first version in practice.
I just want to make things clear, :)
On Thursday, August 4, 2016 at 3:23:11 AM UTC+8, Hotei wrote:
>
> If you create the source as a byte array by converting it ([]byte("abcde")
> then the compiler can NOT optimize it away. However - I don't think it
> will *use* the capacity information in the source since it's not relevant
> and it's going to copy the data bytes and length in any case.
>
> If you're worried about speed impacts I'd suggest benchmarking it. I
> think the second one may be a nanosecond or two slower per copy. If you're
> looking for significant gains from optimizing this I believe you will be
> wasting time looking here.
>
> In my unsolicited opinion the first version is arguably "better", because
> it's easier to read/understand, not because it's faster.
>
>
> I am still not clear about your answer, yes or not?
>>
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.