You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Shoving a bool into an interface probably doesn't need to allocate. I imagine most binaries already have a static 1 byte and a static 0 byte somewhere whose address we could use in the interface's data pointer.
bradfitz@gdev:~$ cat alloc.go
package main
import "testing"
func main() {
var x interface{}
x = true
println(x)
x = false
println(x)
x = true
println(x)
println(testing.AllocsPerRun(5000, func() {
x = true
}))
}
bradfitz@gdev:~$ go run ~/alloc.go
(0x49b960,0xc42003bf4f)
(0x49b960,0xc42003bf4e)
(0x49b960,0xc42003bf4d)
+1.000000e+000