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

Method statelessCompare

cmp/compare.go:223–236  ·  view source on GitHub ↗

statelessCompare compares two values and returns the result. This function is stateless in that it does not alter the current result, or output to any registered reporters.

(step PathStep)

Source from the content-addressed store, hash-verified

221// This function is stateless in that it does not alter the current result,
222// or output to any registered reporters.
223func (s *state) statelessCompare(step PathStep) diff.Result {
224 // We do not save and restore curPath and curPtrs because all of the
225 // compareX methods should properly push and pop from them.
226 // It is an implementation bug if the contents of the paths differ from
227 // when calling this function to when returning from it.
228
229 oldResult, oldReporters := s.result, s.reporters
230 s.result = diff.Result{} // Reset result
231 s.reporters = nil // Remove reporters to avoid spurious printouts
232 s.compareAny(step)
233 res := s.result
234 s.result, s.reporters = oldResult, oldReporters
235 return res
236}
237
238func (s *state) compareAny(step PathStep) {
239 // Update the path stack.

Callers 2

callTRFuncMethod · 0.95
compareSliceMethod · 0.95

Calls 1

compareAnyMethod · 0.95

Tested by

no test coverage detected