Skip to content

Commit c650ec9

Browse files
authored
[chore] [pdata] Use internal.CopyOrigSlice for pcommon.Slice (#13292)
This was missed in #13267
1 parent c6cd1ae commit c650ec9

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

pdata/pcommon/slice.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,7 @@ func (es Slice) All() iter.Seq2[int, Value] {
7878
// CopyTo copies all elements from the current slice overriding the destination.
7979
func (es Slice) CopyTo(dest Slice) {
8080
dest.getState().AssertMutable()
81-
srcLen := es.Len()
82-
destCap := cap(*dest.getOrig())
83-
if srcLen <= destCap {
84-
(*dest.getOrig()) = (*dest.getOrig())[:srcLen:destCap]
85-
} else {
86-
(*dest.getOrig()) = make([]otlpcommon.AnyValue, srcLen)
87-
}
88-
89-
for i := range *es.getOrig() {
90-
newValue(&(*es.getOrig())[i], es.getState()).CopyTo(newValue(&(*dest.getOrig())[i], dest.getState()))
91-
}
81+
*dest.getOrig() = internal.CopyOrigSlice(*dest.getOrig(), *es.getOrig())
9282
}
9383

9484
// EnsureCapacity is an operation that ensures the slice has at least the specified capacity.

0 commit comments

Comments
 (0)