Push indicates intent to descend into pointers vx and vy where visited reports whether either has been seen before. If visited before, equal reports whether both pointers were encountered together. Pop must be called if and only if the pointers were never visited. The pointers vx and vy must be a r
(vx, vy reflect.Value)
| 364 | // The pointers vx and vy must be a reflect.Ptr, reflect.Slice, or reflect.Map |
| 365 | // and be non-nil. |
| 366 | func (p pointerPath) Push(vx, vy reflect.Value) (equal, visited bool) { |
| 367 | px := value.PointerOf(vx) |
| 368 | py := value.PointerOf(vy) |
| 369 | _, ok1 := p.mx[px] |
| 370 | _, ok2 := p.my[py] |
| 371 | if ok1 || ok2 { |
| 372 | equal = p.mx[px] == py && p.my[py] == px // Pointers paired together |
| 373 | return equal, true |
| 374 | } |
| 375 | p.mx[px] = py |
| 376 | p.my[py] = px |
| 377 | return false, false |
| 378 | } |
| 379 | |
| 380 | // Pop ascends from pointers vx and vy. |
| 381 | func (p pointerPath) Pop(vx, vy reflect.Value) { |
no test coverage detected