The compiler could conceivably generate code that did that - and with 
aggressive inlining you would end up the same as native type code. 

I would argue that using raw slices in data structures leads to maintainability 
issues anyway. The key is higher level constructs that give you similar if not 
exact performance. 

After all a slice is a simple data structure whose operators can easily be 
methods on a backing array - and they are :)

> On Jun 22, 2020, at 4:49 PM, Andrew Werner <[email protected]> wrote:
> 
> 
> 
> 
>> On Monday, June 22, 2020 at 5:42:12 PM UTC-4, rog wrote:
>> 
>>>> Thanks for pointing this out. I'm cool with this approach. I'll update my 
>>>> library to utilize it (and consider also adopting the list.List, though I 
>>>> do like my freedom to pool list nodes).
>> 
>> 
>> Personally, I'd start by re-using list.List, and only use pools if there 
>> really is a significant performance benefit to be gained there.
>> If you just need zero-valued elements, I could imagine that sync.Pool might 
>> end up slower than just using the GC.
> 
> Fair. 
> 
>> 
>>>> Hopefully with aggressive inlining of the specialized type the compiler 
>>>> will be able to make the optimizations that it would be able to make if 
>>>> the slicing were performed directly on an array.
>> 
>> 
>> What optimisations are you thinking of here? Are you concerned that slice 
>> operations are too slow?
> 
> 
> * Bound check elimination
> * Avoiding an indirection through the pointer in the slice header would be 
> nice
> * Compile-time evaluation of len and cap
> 
> IIUC all of these would happen if we were operating on a raw array type 
> rather than a slice. 
> 
>> 
>>   cheers,
>>     rog.
> 
> -- 
> 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].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/6a6bd9d6-deec-42f2-a9d8-7a1413221f4do%40googlegroups.com.

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/C77858DE-4622-4E5F-B58E-9789F9777B43%40ix.netcom.com.

Reply via email to