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

2018-08-13 Thread Peter Edge
g.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, but keep the backing slice with the > > same capacity (although the el

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