|
@@ -70,9 +70,9 @@ func (p *Profile) preEncode() {
|
70
|
70
|
)
|
71
|
71
|
}
|
72
|
72
|
}
|
73
|
|
- s.locationIDX = nil
|
74
|
|
- for _, l := range s.Location {
|
75
|
|
- s.locationIDX = append(s.locationIDX, l.ID)
|
|
73
|
+ s.locationIDX = make([]uint64, len(s.Location))
|
|
74
|
+ for i, loc := range s.Location {
|
|
75
|
+ s.locationIDX[i] = loc.ID
|
76
|
76
|
}
|
77
|
77
|
}
|
78
|
78
|
|
|
@@ -177,9 +177,13 @@ var profileDecoder = []decoder{
|
177
|
177
|
// repeated Location location = 4
|
178
|
178
|
func(b *buffer, m message) error {
|
179
|
179
|
x := new(Location)
|
|
180
|
+ x.Line = make([]Line, 0, 8) // Pre-allocate Line buffer
|
180
|
181
|
pp := m.(*Profile)
|
181
|
182
|
pp.Location = append(pp.Location, x)
|
182
|
|
- return decodeMessage(b, x)
|
|
183
|
+ err := decodeMessage(b, x)
|
|
184
|
+ var tmp []Line
|
|
185
|
+ x.Line = append(tmp, x.Line...) // Shrink to allocated size
|
|
186
|
+ return err
|
183
|
187
|
},
|
184
|
188
|
// repeated Function function = 5
|
185
|
189
|
func(b *buffer, m message) error {
|
|
@@ -282,9 +286,9 @@ func (p *Profile) postDecode() error {
|
282
|
286
|
if len(numLabels) > 0 {
|
283
|
287
|
s.NumLabel = numLabels
|
284
|
288
|
}
|
285
|
|
- s.Location = nil
|
286
|
|
- for _, lid := range s.locationIDX {
|
287
|
|
- s.Location = append(s.Location, locations[lid])
|
|
289
|
+ s.Location = make([]*Location, len(s.locationIDX))
|
|
290
|
+ for i, lid := range s.locationIDX {
|
|
291
|
+ s.Location[i] = locations[lid]
|
288
|
292
|
}
|
289
|
293
|
s.locationIDX = nil
|
290
|
294
|
}
|