mirror of
https://github.com/golang/go
synced 2024-11-22 18:44:54 -07:00
reflect: record unsafe.Pointer, not uintptr, during DeepEqual
This is more correct with respect to garbage collection. I don't know of any specific failures it could cause today. Change-Id: I7eed6a06d2f281051199e79e4a9913aa8360ded7 Reviewed-on: https://go-review.googlesource.com/14137 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
ace303297f
commit
928fe05a4f
@ -6,13 +6,15 @@
|
||||
|
||||
package reflect
|
||||
|
||||
import "unsafe"
|
||||
|
||||
// During deepValueEqual, must keep track of checks that are
|
||||
// in progress. The comparison algorithm assumes that all
|
||||
// checks in progress are true when it reencounters them.
|
||||
// Visited comparisons are stored in a map indexed by visit.
|
||||
type visit struct {
|
||||
a1 uintptr
|
||||
a2 uintptr
|
||||
a1 unsafe.Pointer
|
||||
a2 unsafe.Pointer
|
||||
typ Type
|
||||
}
|
||||
|
||||
@ -37,9 +39,9 @@ func deepValueEqual(v1, v2 Value, visited map[visit]bool, depth int) bool {
|
||||
}
|
||||
|
||||
if v1.CanAddr() && v2.CanAddr() && hard(v1.Kind()) {
|
||||
addr1 := v1.UnsafeAddr()
|
||||
addr2 := v2.UnsafeAddr()
|
||||
if addr1 > addr2 {
|
||||
addr1 := unsafe.Pointer(v1.UnsafeAddr())
|
||||
addr2 := unsafe.Pointer(v2.UnsafeAddr())
|
||||
if uintptr(addr1) > uintptr(addr2) {
|
||||
// Canonicalize order to reduce number of entries in visited.
|
||||
addr1, addr2 = addr2, addr1
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user