Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2)

Side by Side Diff: src/pkg/reflect/deepequal.go

Issue 4433066: code review 4433066: reflect: rename Typeof, NewValue -> TypeOf, ValueOf (Closed)
Patch Set: diff -r ecf1f7266354 https://go.googlecode.com/hg Created 13 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/reflect/all_test.go ('k') | src/pkg/reflect/set_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Deep equality test via reflection 5 // Deep equality test via reflection
6 6
7 package reflect 7 package reflect
8 8
9 // During deepValueEqual, must keep track of checks that are 9 // During deepValueEqual, must keep track of checks that are
10 // in progress. The comparison algorithm assumes that all 10 // in progress. The comparison algorithm assumes that all
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 panic("Not reached") 110 panic("Not reached")
111 } 111 }
112 112
113 // DeepEqual tests for deep equality. It uses normal == equality where possible 113 // DeepEqual tests for deep equality. It uses normal == equality where possible
114 // but will scan members of arrays, slices, and fields of structs. It correctly 114 // but will scan members of arrays, slices, and fields of structs. It correctly
115 // handles recursive types. 115 // handles recursive types.
116 func DeepEqual(a1, a2 interface{}) bool { 116 func DeepEqual(a1, a2 interface{}) bool {
117 if a1 == nil || a2 == nil { 117 if a1 == nil || a2 == nil {
118 return a1 == a2 118 return a1 == a2
119 } 119 }
120 » v1 := NewValue(a1) 120 » v1 := ValueOf(a1)
121 » v2 := NewValue(a2) 121 » v2 := ValueOf(a2)
122 if v1.Type() != v2.Type() { 122 if v1.Type() != v2.Type() {
123 return false 123 return false
124 } 124 }
125 return deepValueEqual(v1, v2, make(map[uintptr]*visit), 0) 125 return deepValueEqual(v1, v2, make(map[uintptr]*visit), 0)
126 } 126 }
OLDNEW
« no previous file with comments | « src/pkg/reflect/all_test.go ('k') | src/pkg/reflect/set_test.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b