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