Re: [go-nuts] slice of pointer of struct vs slice of struct

2017-10-20 Thread Bakul Shah
On Fri, 20 Oct 2017 09:09:15 - Jan Mercl <0xj...@gmail.com> wrote: Jan Mercl writes: > > On Fri, Oct 20, 2017 at 11:07 AM Bakul Shah wrote: > > > On the flip side, []*T will be less cache/TLB/GC friendly than > > []T, unless T is much larger than a ptr. You are also > > allocating an extra p

Re: [go-nuts] slice of pointer of struct vs slice of struct

2017-10-20 Thread Jan Mercl
On Fri, Oct 20, 2017 at 11:07 AM Bakul Shah wrote: > On the flip side, []*T will be less cache/TLB/GC friendly than > []T, unless T is much larger than a ptr. You are also > allocating an extra pointer per element. For small slices it > probably doesn't matter much either way but when slices hold

Re: [go-nuts] slice of pointer of struct vs slice of struct

2017-10-20 Thread Bakul Shah
On Fri, 20 Oct 2017 08:49:16 - Jan Mercl <0xj...@gmail.com> wrote: Jan Mercl writes: > > On Fri, Oct 20, 2017 at 10:39 AM Ian Davis wrote: > > > How does that affect the size of []T or []*T ? > > No one said it does. What size of T affects is appending/inserting/deleting > items to/from the

Re: [go-nuts] slice of pointer of struct vs slice of struct

2017-10-20 Thread Jan Mercl
On Fri, Oct 20, 2017 at 10:39 AM Ian Davis wrote: > How does that affect the size of []T or []*T ? No one said it does. What size of T affects is appending/inserting/deleting items to/from the slice. If one passes around a value of type []T, those operations are probably performed on the value.

Re: [go-nuts] slice of pointer of struct vs slice of struct

2017-10-20 Thread Ian Davis
On Fri, 20 Oct 2017, at 06:34 AM, Jan Mercl wrote: > On Fri, Oct 20, 2017 at 7:25 AM Feby Tanzil > wrote:> > > Which is better & preferable in Go? > > Depends on size of T. How does that affect the size of []T or []*T ? Ian -- You received this message because you are subscribed to the Goog

Re: [go-nuts] slice of pointer of struct vs slice of struct

2017-10-20 Thread roger peppe
On 20 October 2017 at 05:15, Feby Tanzil wrote: > Hi, > > I got vague answers in the internet over this. > Which is better & preferable in Go? > > type T struct { > // some attributes > ... > } > > func a() []T { > > } > > func b() []*T { > > } Both are plausible. It depends what you're going t

Re: [go-nuts] slice of pointer of struct vs slice of struct

2017-10-19 Thread Jan Mercl
On Fri, Oct 20, 2017 at 7:25 AM Feby Tanzil wrote: > Which is better & preferable in Go? Depends on size of T. -- -j -- 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 e

[go-nuts] slice of pointer of struct vs slice of struct

2017-10-19 Thread Feby Tanzil
Hi, I got vague answers in the internet over this. Which is better & preferable in Go? type T struct { // some attributes ... } func a() []T { } func b() []*T { } Thanks -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe fr