summaryrefslogtreecommitdiff
path: root/libgo/go/reflect/deepequal.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2020-12-23 09:57:37 -0800
committerIan Lance Taylor <iant@golang.org>2020-12-30 15:13:24 -0800
commitcfcbb4227fb20191e04eb8d7766ae6202f526afd (patch)
treee2effea96f6f204451779f044415c2385e45042b /libgo/go/reflect/deepequal.go
parent0696141107d61483f38482b941549959a0d7f613 (diff)
downloadgcc-cfcbb4227fb20191e04eb8d7766ae6202f526afd.tar.gz
libgo: update to Go1.16beta1 release
This does not yet include support for the //go:embed directive added in this release. * Makefile.am (check-runtime): Don't create check-runtime-dir. (mostlyclean-local): Don't remove check-runtime-dir. (check-go-tool, check-vet): Copy in go.mod and modules.txt. (check-cgo-test, check-carchive-test): Add go.mod file. * Makefile.in: Regenerate. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/280172
Diffstat (limited to 'libgo/go/reflect/deepequal.go')
-rw-r--r--libgo/go/reflect/deepequal.go18
1 files changed, 8 insertions, 10 deletions
diff --git a/libgo/go/reflect/deepequal.go b/libgo/go/reflect/deepequal.go
index b99c345e7bf..d951d8d9997 100644
--- a/libgo/go/reflect/deepequal.go
+++ b/libgo/go/reflect/deepequal.go
@@ -21,7 +21,7 @@ type visit struct {
// Tests for deep equality using reflected types. The map argument tracks
// comparisons that have already been seen, which allows short circuiting on
// recursive types.
-func deepValueEqual(v1, v2 Value, visited map[visit]bool, depth int) bool {
+func deepValueEqual(v1, v2 Value, visited map[visit]bool) bool {
if !v1.IsValid() || !v2.IsValid() {
return v1.IsValid() == v2.IsValid()
}
@@ -29,8 +29,6 @@ func deepValueEqual(v1, v2 Value, visited map[visit]bool, depth int) bool {
return false
}
- // if depth > 10 { panic("deepValueEqual") } // for debugging
-
// We want to avoid putting more in the visited map than we need to.
// For any possible reference cycle that might be encountered,
// hard(v1, v2) needs to return true for at least one of the types in the cycle,
@@ -89,7 +87,7 @@ func deepValueEqual(v1, v2 Value, visited map[visit]bool, depth int) bool {
switch v1.Kind() {
case Array:
for i := 0; i < v1.Len(); i++ {
- if !deepValueEqual(v1.Index(i), v2.Index(i), visited, depth+1) {
+ if !deepValueEqual(v1.Index(i), v2.Index(i), visited) {
return false
}
}
@@ -105,7 +103,7 @@ func deepValueEqual(v1, v2 Value, visited map[visit]bool, depth int) bool {
return true
}
for i := 0; i < v1.Len(); i++ {
- if !deepValueEqual(v1.Index(i), v2.Index(i), visited, depth+1) {
+ if !deepValueEqual(v1.Index(i), v2.Index(i), visited) {
return false
}
}
@@ -114,15 +112,15 @@ func deepValueEqual(v1, v2 Value, visited map[visit]bool, depth int) bool {
if v1.IsNil() || v2.IsNil() {
return v1.IsNil() == v2.IsNil()
}
- return deepValueEqual(v1.Elem(), v2.Elem(), visited, depth+1)
+ return deepValueEqual(v1.Elem(), v2.Elem(), visited)
case Ptr:
if v1.Pointer() == v2.Pointer() {
return true
}
- return deepValueEqual(v1.Elem(), v2.Elem(), visited, depth+1)
+ return deepValueEqual(v1.Elem(), v2.Elem(), visited)
case Struct:
for i, n := 0, v1.NumField(); i < n; i++ {
- if !deepValueEqual(v1.Field(i), v2.Field(i), visited, depth+1) {
+ if !deepValueEqual(v1.Field(i), v2.Field(i), visited) {
return false
}
}
@@ -140,7 +138,7 @@ func deepValueEqual(v1, v2 Value, visited map[visit]bool, depth int) bool {
for _, k := range v1.MapKeys() {
val1 := v1.MapIndex(k)
val2 := v2.MapIndex(k)
- if !val1.IsValid() || !val2.IsValid() || !deepValueEqual(val1, val2, visited, depth+1) {
+ if !val1.IsValid() || !val2.IsValid() || !deepValueEqual(val1, val2, visited) {
return false
}
}
@@ -217,5 +215,5 @@ func DeepEqual(x, y interface{}) bool {
if v1.Type() != v2.Type() {
return false
}
- return deepValueEqual(v1, v2, make(map[visit]bool), 0)
+ return deepValueEqual(v1, v2, make(map[visit]bool))
}