Source file
test/escape_make_non_const.go
1
2
3
4
5
6
7 package escape
8
9 const globalConstSize = 128
10
11 var globalVarSize = 128
12
13
14 func testSlices() {
15 {
16 size := 128
17 _ = make([]byte, size)
18 }
19
20 {
21 s := 128
22 size := s
23 _ = make([]byte, size)
24 }
25
26 {
27 size := 128
28 _ = make([]byte, size)
29 }
30
31 {
32 s := 128
33 size := s
34 _ = make([]byte, size)
35 }
36
37 {
38 s1 := 128
39 s2 := 256
40 _ = make([]byte, s2, s1)
41 }
42
43 allocLen(256)
44 allocCap(256)
45 _ = newT(256)
46
47 {
48 size := globalConstSize
49 _ = make([]byte, size)
50 }
51
52 allocLen(globalConstSize)
53 allocCap(globalConstSize)
54 _ = newT(globalConstSize)
55
56 {
57 c := 128
58 s := 256
59 _ = make([]byte, s, c)
60 }
61
62 {
63 s := 256
64 _ = make([]byte, s, globalConstSize)
65 }
66
67 {
68 _ = make([]byte, globalVarSize)
69 _ = make([]byte, globalVarSize, globalConstSize)
70 }
71 }
72
73 func allocLen(l int) []byte {
74 return make([]byte, l)
75 }
76
77 func allocCap(l int) []byte {
78 return make([]byte, 0, l)
79 }
80
81 type t struct {
82 s []byte
83 }
84
85 func newT(l int) t {
86 return t{make([]byte, l)}
87 }
88
89
90 func testMaps() {
91 size := 128
92 _ = make(map[string]int, size)
93
94 _ = allocMapLen(128)
95 _ = newM(128)
96 }
97
98 func allocMapLen(l int) map[string]int {
99 return make(map[string]int, l)
100 }
101
102 type m struct {
103 m map[string]int
104 }
105
106 func newM(l int) m {
107 return m{make(map[string]int, l)}
108 }
109
View as plain text