From 6f1960017c3f3f96d5c5fbaebf26b06687d413fa Mon Sep 17 00:00:00 2001 From: Peter Turi Date: Sat, 3 Feb 2024 12:45:23 +0100 Subject: [PATCH] Fix scan doing ** Given that the reflect.New already returns a pointer to the type, this additional Pointer caused the Scan to receive ** The issue with this is that golang's database package contains optimizations for single pointer types, and thus doesn't use reflection. This patch (in my benchmarks) decreases CPU usage by 10% and memory usage by 10%. --- schema/field.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/field.go b/schema/field.go index 657e0a4b..49742723 100644 --- a/schema/field.go +++ b/schema/field.go @@ -985,6 +985,6 @@ func (field *Field) setupNewValuePool() { } if field.NewValuePool == nil { - field.NewValuePool = poolInitializer(reflect.PtrTo(field.IndirectFieldType)) + field.NewValuePool = poolInitializer(field.IndirectFieldType) } }