On Wed, Aug 3, 2016 at 9:12 AM, T L <tapir....@gmail.com> wrote:
>
> On Wednesday, August 3, 2016 at 11:46:43 PM UTC+8, Axel Wagner wrote:
>>
>> True, but it would still be just the same loop, it wouldn't actually be
>> significantly faster. And you'd need to put quite some machinery into a
>> pretty rarely used functionality, which means it also wouldn't be cleaner.
>>
>> The thing is, that the memory representation of []T and []J, with J being
>> an interface type, is very different form each other and differs also for
>> each (T, J) pair, AIUI. So you can't really efficiently generalize this. The
>> only thing it could possibly safe you, is writing the actual loop and in
>> general go doesn't really do this kind of tradeoff (saving small amounts of
>> trivial work by complicating the language and -implementation).
>
>
> so the copy buitlin function is not essential?

Correct.

Although it is worth noting that, in the absence of significant
compiler optimizations that the gc compiler does not currently
implement, the copy builtin can be much more efficient than the
ordinary user written loop; see
https://golang.org/src/runtime/memmove_amd64.s.  That is not true of a
function that converts from []T to []interface.

Ian

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