]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: record unsafe.Pointer, not uintptr, during DeepEqual
authorRuss Cox <rsc@golang.org>
Tue, 1 Sep 2015 03:41:27 +0000 (23:41 -0400)
committerRuss Cox <rsc@golang.org>
Sat, 5 Sep 2015 01:44:30 +0000 (01:44 +0000)
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>
src/reflect/deepequal.go

index f63715c9afc9862681422180aa4ba08b078215c2..e777ca45ce4011d22367b10f64c99ff296ad40f1 100644 (file)
@@ -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
                }