// example1.go
packge main
func main() {
s := make([]byte, 1024, 1024)
_ = s
}
s will be allocated in stack and lookup assemble code not call runtime.makeslice
// example2.go
packge main
func main() {
cap := 1024
s := make([]byte, 1024, cap)
_ = s
}
s will be allocated in heap and lookup assemble code there is runtime.makeslice why this ???
// example3.go
package main
func main() {
a := 100
if a>1 {
a = 1000
}
b := interface{}(a)
_ = b
}
lookup the assemble code and see the compiler is very clever to opt that but in example2.go why don't do this