mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 17:18:35 +08:00
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>
This commit is contained in:
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…
x
Reference in New Issue
Block a user