diff options
| author | qiulaidongfeng <2645477756@qq.com> | 2024-01-23 00:42:58 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-01-23 17:19:58 +0000 |
| commit | 8c45dddd5de44a5c2f469d80195f8347d7baa41c (patch) | |
| tree | d8fdbc82c1e69bc276904da2ae113a5a4752f08a | |
| parent | f75e1c1460a009ee3feb9fbd34fc17b957644dc5 (diff) | |
| download | go-8c45dddd5de44a5c2f469d80195f8347d7baa41c.tar.xz | |
reflect: delete TODO pass safe to packEface don't need to copy if safe==true
valueInterface not copy result in the follow incorrect behavior
w1. x := ValueOf(&v).Elem()
r1. iface := Value.Interface()
w2. x.Set() or x.SetT()
The write operation of W2 will be observed by the read operation of r1,
but the existing behavior is not.
The valueInterface in deepValueEqual can, in theory, pass safe==true to not copy the object,
but there is no benchmark to indicate that the memory allocation has changed,
maybe we don't actually need safe==true here.
Change-Id: I55c423fd50adac8822a7fdbfe67af89ee223eace
GitHub-Last-Rev: 4a6386709817f3ea6055711dd39d2694d58b3043
GitHub-Pull-Request: golang/go#64618
Reviewed-on: https://go-review.googlesource.com/c/go/+/548436
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
| -rw-r--r-- | src/reflect/value.go | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/src/reflect/value.go b/src/reflect/value.go index 06f22f7428..8f163fce16 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -129,8 +129,6 @@ func packEface(v Value) any { // Value is indirect, and so is the interface we're making. ptr := v.ptr if v.flag&flagAddr != 0 { - // TODO: pass safe boolean from valueInterface so - // we don't need to copy if safe==true? c := unsafe_New(t) typedmemmove(t, c, ptr) ptr = c @@ -1522,7 +1520,6 @@ func valueInterface(v Value, safe bool) any { })(v.ptr) } - // TODO: pass safe to packEface so we don't need to copy if safe==true? return packEface(v) } |
