profiling/memory/efficient.go (8 lines of code) (raw):

package memory func EfficientAppend(n int) []int { result := make([]int, 0, n) for i := 0; i < n; i++ { result = append(result, i) } return result }