]> Cypherpunks.ru repositories - gostls13.git/blob - test/sliceopt.go
cmd/internal/gc: optimize append + write barrier
[gostls13.git] / test / sliceopt.go
1 // errorcheck -0 -d=append
2
3 // Copyright 2015 The Go Authors.  All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6
7 // Check optimization results for append.
8
9 package main
10
11 func a1(x []int, y int) []int {
12         x = append(x, y) // ERROR "append: len-only update"
13         return x
14 }
15
16 func a2(x []int, y int) []int {
17         return append(x, y) // ERROR "append: full update"
18 }
19
20 func a3(x *[]int, y int) {
21         *x = append(*x, y) // ERROR "append: len-only update"
22 }