Skip to content

Commit

Permalink
Use copySlice only once for LocationIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
simonswine committed Jul 13, 2022
1 parent a74e57b commit e4585a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 3 additions & 1 deletion pkg/firedb/head.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ func (h *Head) convertSamples(ctx context.Context, r *rewriter, in []*profilev1.

// build full stack traces
stacktraces[pos] = &schemav1.Stacktrace{
LocationIDs: copySlice(in[pos].LocationId),
// no copySlice necessary at this point,stacktracesHelper.clone
// will copy it, if it is required to be retained.
LocationIDs: in[pos].LocationId,
}
}

Expand Down
6 changes: 1 addition & 5 deletions pkg/firedb/stacktraces.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ func (*stacktracesHelper) size(s *schemav1.Stacktrace) uint64 {
}

func (*stacktracesHelper) clone(s *schemav1.Stacktrace) *schemav1.Stacktrace {
locationIDs := make([]uint64, len(s.LocationIDs))
for pos := range locationIDs {
locationIDs[pos] = s.LocationIDs[pos]
}
s.LocationIDs = locationIDs
s.LocationIDs = copySlice(s.LocationIDs)
return s
}

0 comments on commit e4585a6

Please sign in to comment.