MCPcopy
hub / github.com/google/go-cmp / Push

Method Push

cmp/path.go:366–378  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

364// The pointers vx and vy must be a reflect.Ptr, reflect.Slice, or reflect.Map
365// and be non-nil.
366func (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.
381func (p pointerPath) Pop(vx, vy reflect.Value) {

Callers 4

compareAnyMethod · 0.45
compareMapMethod · 0.45
comparePtrMethod · 0.45
FormatValueMethod · 0.45

Calls 1

PointerOfFunction · 0.92

Tested by

no test coverage detected