profiling/memory/inefficient.go (9 lines of code) (raw):

package memory func InefficientAppend(n int) []int { result := []int{} for i := 0; i < n; i++ { tmp := []int{i} // new slice created in each loop iteration result = append(result, tmp...) } return result }