MCPcopy Index your code
hub / github.com/cockroachdb/errors / ElideSharedStackTraceSuffix

Function ElideSharedStackTraceSuffix

errbase/format_error.go:956–976  ·  view source on GitHub ↗

ElideSharedStackTraceSuffix removes the suffix of newStack that's already present in prevStack. The function returns true if some entries were elided.

(prevStack, newStack StackTrace)

Source from the content-addressed store, hash-verified

954// present in prevStack. The function returns true if some entries
955// were elided.
956func ElideSharedStackTraceSuffix(prevStack, newStack StackTrace) (StackTrace, bool) {
957 if len(prevStack) == 0 {
958 return newStack, false
959 }
960 if len(newStack) == 0 {
961 return newStack, false
962 }
963
964 // Skip over the common suffix.
965 var i, j int
966 for i, j = len(newStack)-1, len(prevStack)-1; i > 0 && j > 0; i, j = i-1, j-1 {
967 if newStack[i] != prevStack[j] {
968 break
969 }
970 }
971 if i == 0 {
972 // Keep at least one entry.
973 i = 1
974 }
975 return newStack[:i], i < len(newStack)-1
976}
977
978// StackTrace is the type of the data for a call stack.
979// This mirrors the type of the same name in github.com/pkg/errors.

Callers 4

TestSimplifyStacksFunction · 0.92
formatRecursiveMethod · 0.85
enhanceArgsMethod · 0.85
enhanceArgsMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestSimplifyStacksFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…