From 8925290cf701fc8f7ec95e4df3d6a8d423b26780 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Fri, 18 Sep 2020 14:19:22 -0700 Subject: reflect: use zero buffer to back the Value returned by Zero MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the common case (<1KB types), no allocation is required by reflect.Zero. Also use memclr instead of memmove in Set when the source is known to be zero. Fixes #33136 Change-Id: Ic66871930fbb53328032e587153ebd12995ccf55 Reviewed-on: https://go-review.googlesource.com/c/go/+/192331 Trust: Keith Randall Run-TryBot: Keith Randall TryBot-Result: Go Bot Reviewed-by: Martin Möhrmann --- src/runtime/map.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/runtime') diff --git a/src/runtime/map.go b/src/runtime/map.go index 8be1d3991d..6f31f23d6f 100644 --- a/src/runtime/map.go +++ b/src/runtime/map.go @@ -1380,5 +1380,5 @@ func reflectlite_maplen(h *hmap) int { return h.count } -const maxZero = 1024 // must match value in cmd/compile/internal/gc/walk.go:zeroValSize +const maxZero = 1024 // must match value in reflect/value.go:maxZero cmd/compile/internal/gc/walk.go:zeroValSize var zeroVal [maxZero]byte -- cgit v1.3-5-g9baa