Open
Description
In this function, func hi() string { b := make([]byte, 0, 100) // 1st alloc b = append(b, "Hello, "...) b = append(b, "world.\n"...) return string(b) // 2nd alloc, but could be removed. } The final line currently generates a call to runtime.slicebytetostring, causing a copy of b to be allocated. But the compiler already knows that b doesn't escape. It could instead return a string header re-using the []byte memory.