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

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

[go-nuts] Re: Eliminating redundant map lookups

2016-11-27 Thread Andrei Tudor Călin
In general, a good way to answer questions like this is to inspect an assembly listing for the code. This is what I compiled: $ cat foo.go package foo import ( "fmt" ) type Person struct { Name string Likes []string } func foo() { var people []*Person likes := make(map[string][]*Person) for

[go-nuts] Re: Eliminating redundant map lookups

2016-11-27 Thread stinkingmadgod
I should clarify that this actually came up in practice and I have no clue on how I can eliminate them -- 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