DEV Community

Discussion on: My journey optimizing the Go Compiler

Collapse
 
xzf profile image
xzf

func mapImplementation() int {
return map[string]int{
"amd64": 0,
"arm": 1,
"arm64": 2,
}[runtime.GOARCH]
}

what are you thinking?

Collapse
 
segflow profile image
Assel Meher • Edited

That's the function used the benchmark the single lookup using a const literal on a literal map, and compared to the switch one yes it's 96 slower, of course, I'm talking slower on my MAC.
I already said, that optimizing that is somewhat unnecessary. But with that PR that function becomes similar to a func mapImplementation () int { return 0 }. This means there is no map allocation at all.

Collapse
 
xzf profile image
xzf

each time alloc a map ?

96 times slower!!!! lol