mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
Buffer and engine metrics were sharing ownership to one array. Fix is to copy the array.
13 lines
372 B
Go
13 lines
372 B
Go
package util
|
|
|
|
// Clone returns a copy of the slice.
|
|
// The elements are copied using assignment, so this is a shallow clone.
|
|
// The difference with slices.Clone is that the result will not have additional unused capacity.
|
|
func Clone[S ~[]E, E any](s S) S {
|
|
// Preserve nilness in case it matters.
|
|
if s == nil {
|
|
return nil
|
|
}
|
|
return append(make(S, 0, len(s)), s...)
|
|
}
|