1
0
mirror of https://github.com/golang/go synced 2024-11-17 22:05:02 -07:00

reflect: reuse values during comparison of maps in DeepEqual

Change-Id: I82f999b8ed9434321a361bf1bcbed7cf6ee4bee6
Reviewed-on: https://go-review.googlesource.com/115475
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Zhou Peng 2018-05-31 06:52:19 +00:00 committed by Brad Fitzpatrick
parent 08e2e880e7
commit c4f9fa1f8e

View File

@ -116,7 +116,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(v1.MapIndex(k), v2.MapIndex(k), visited, depth+1) {
if !val1.IsValid() || !val2.IsValid() || !deepValueEqual(val1, val2, visited, depth+1) {
return false
}
}