Re: [go-nuts] Is there a way to clear a map similar to slice = slice[:0]?

2018-11-28 Thread Michael Jones
[old post...bumping] why not delete(map) with the obvious meaning On Mon, Aug 13, 2018 at 7:43 AM Peter Edge wrote: > Yes, actually saw that a bit after I sent this email. Thanks for the link > though, appreciate it :-) > > On Mon, Aug 13, 2018 at 11:08 AM roger peppe wrote: > >> I believe thi

Re: [go-nuts] Is there a way to clear a map similar to slice = slice[:0]?

2018-08-13 Thread Peter Edge
Yes, actually saw that a bit after I sent this email. Thanks for the link though, appreciate it :-) On Mon, Aug 13, 2018 at 11:08 AM roger peppe wrote: > I believe this optimisation has been implemented now. > Have you tried using Go 1.11 beta (or Go tip) ? > See https://tip.golang.org/doc/go1.1

Re: [go-nuts] Is there a way to clear a map similar to slice = slice[:0]?

2018-08-13 Thread roger peppe
I believe this optimisation has been implemented now. Have you tried using Go 1.11 beta (or Go tip) ? See https://tip.golang.org/doc/go1.11#performance-compiler On 12 August 2018 at 11:07, Peter Edge wrote: > With slices, you can do > > slice = slice[:0] > > to remove the values from the slice,

[go-nuts] Is there a way to clear a map similar to slice = slice[:0]?

2018-08-12 Thread Peter Edge
With slices, you can do slice = slice[:0] to remove the values from the slice, but keep the backing slice with the same capacity (although the elements aren't marked for GC I believe, if that's a concern). With maps, is there a similar pattern? I've tried: for key := range m { delete(m, key)