Re: [go-nuts] Re: Eliminating redundant map lookups

2016-11-27 Thread 'Keith Randall' via golang-nuts
Yes, it currently requires two lookups (two hashes, two bucket searches, etc.). This general problem is issue 17133 (https://github.com/golang/go/issues/17133). Your example has the extra complication that the update operation is an append, not just a +=. On Sunday, November 27, 2016 at 7:00

Re: [go-nuts] Re: Eliminating redundant map lookups

2016-11-27 Thread 'Ian Cottrell' via golang-nuts
Yes you will get two map operations happen, one lookup and one assign. Wrapping the code into a (mildly modified for pretty output) runnable example: https://play.golang.org/p/oGKvfS9ssH In the basic case of a new key, there is no way to avoid doing both a lookup and assign, but in the case where