@@ -15,10 +15,10 @@ type visited struct {
15
15
rhs []uintptr
16
16
}
17
17
18
- // add will try to add the value's pointers to the list. It will return an error
18
+ // push will try to add the value's pointers to the list. It will return an error
19
19
// if the value is already in the list.
20
20
// visited.remove should be called whether an error occured or not.
21
- func (v * visited ) add (lhs , rhs reflect.Value ) error {
21
+ func (v * visited ) push (lhs , rhs reflect.Value ) error {
22
22
if canAddr (lhs ) && ! isEmptyMapOrSlice (lhs ) {
23
23
if inPointers (v .lhs , lhs .Pointer ()) {
24
24
return ErrCyclic
@@ -35,22 +35,22 @@ func (v *visited) add(lhs, rhs reflect.Value) error {
35
35
return nil
36
36
}
37
37
38
- func (v * visited ) remove (lhs , rhs reflect.Value ) {
39
- if canAddr (lhs ) && isLastPointer (v .lhs , lhs .Pointer ()) {
38
+ func (v * visited ) pop (lhs , rhs reflect.Value ) {
39
+ if canAddr (lhs ) && lastElementEquals (v .lhs , lhs .Pointer ()) {
40
40
v .lhs = v .lhs [:len (v .lhs )- 1 ]
41
41
}
42
42
43
- if canAddr (rhs ) && isLastPointer (v .rhs , rhs .Pointer ()) {
43
+ if canAddr (rhs ) && lastElementEquals (v .rhs , rhs .Pointer ()) {
44
44
v .rhs = v .rhs [:len (v .rhs )- 1 ]
45
45
}
46
46
}
47
47
48
- func isLastPointer ( pointers []uintptr , val uintptr ) bool {
49
- if len (pointers ) == 0 {
48
+ func lastElementEquals ( uu []uintptr , val uintptr ) bool {
49
+ if len (uu ) == 0 {
50
50
return false
51
51
}
52
52
53
- return pointers [len (pointers )- 1 ] == val
53
+ return uu [len (uu )- 1 ] == val
54
54
}
55
55
56
56
func isEmptyMapOrSlice (v reflect.Value ) bool {
0 commit comments