mirror of https://github.com/milvus-io/milvus.git
Optimize the generic zero value (#27102)
allocate by declare, this make it possible to allocate the value in stack, faster and less presure for GC Signed-off-by: yah01 <yah2er0ne@outlook.com>pull/27109/head
parent
7bb20fa394
commit
0f2883ef9d
|
@ -19,7 +19,8 @@ package generic
|
|||
import "reflect"
|
||||
|
||||
func Zero[T any]() T {
|
||||
return *new(T)
|
||||
var zero T
|
||||
return zero
|
||||
}
|
||||
|
||||
func IsZero[T any](v T) bool {
|
||||
|
|
Loading…
Reference in New Issue