From 23ca33009571a55eda926b7a41f5ceb04277bbd9 Mon Sep 17 00:00:00 2001 From: Cherry Mui Date: Wed, 15 Nov 2023 21:35:37 -0500 Subject: [PATCH] reflect: remove go121noForceValueEscape Before Go 1.21, ValueOf always escapes and a Value's content is always heap allocated. In Go 1.21, we made it no longer always escape, guarded by go121noForceValueEscape. This behavior has been released for some time and there is no issue so far. We can remove the guard now. Change-Id: I81f5366412390f6c63b642f4c7c016da534da76a Reviewed-on: https://go-review.googlesource.com/c/go/+/542795 Reviewed-by: David Chase LUCI-TryBot-Result: Go LUCI --- src/reflect/value.go | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/reflect/value.go b/src/reflect/value.go index 705d74f6b8..5bfdb55fd9 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -3232,25 +3232,12 @@ func Indirect(v Value) Value { return v.Elem() } -// Before Go 1.21, ValueOf always escapes and a Value's content -// is always heap allocated. -// Set go121noForceValueEscape to true to avoid the forced escape, -// allowing Value content to be on the stack. -// Set go121noForceValueEscape to false for the legacy behavior -// (for debugging). -const go121noForceValueEscape = true - // ValueOf returns a new Value initialized to the concrete value // stored in the interface i. ValueOf(nil) returns the zero Value. func ValueOf(i any) Value { if i == nil { return Value{} } - - if !go121noForceValueEscape { - escapes(i) - } - return unpackEface(i) } -- 2.51.0