From 8d5fd7342eb72283f681ef0a09e4be84a7b5cab4 Mon Sep 17 00:00:00 2001 From: yihong Date: Mon, 1 Sep 2025 12:55:34 +0800 Subject: [PATCH] fix: can replace a copy with slices in vector (#63291) ref pingcap/tidb#62543 --- pkg/types/vector.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/types/vector.go b/pkg/types/vector.go index 071230bc74..54eaddf066 100644 --- a/pkg/types/vector.go +++ b/pkg/types/vector.go @@ -18,6 +18,7 @@ import ( "encoding/binary" "fmt" "math" + "slices" "strconv" "strings" "unsafe" @@ -278,9 +279,7 @@ func ParseVectorFloat32(s string) (VectorFloat32, error) { // Clone returns a deep copy of the vector. func (v VectorFloat32) Clone() VectorFloat32 { - data := make([]byte, len(v.data)) - copy(data, v.data) - return VectorFloat32{data: data} + return VectorFloat32{data: slices.Clone(v.data)} } // IsZeroValue returns true if the vector is a zero value (which length is zero).