MCPcopy Index your code
hub / github.com/go-git/go-git / DoWithTimeout

Function DoWithTimeout

utils/diff/diff.go:32–39  ·  view source on GitHub ↗

DoWithTimeout computes the (line oriented) modifications needed to turn the src string into the dst string. The `timeout` argument specifies the maximum amount of time it is allowed to spend in this function. If the timeout is exceeded, the parts of the strings which were not considered are turned i

(src, dst string, timeout time.Duration)

Source from the content-addressed store, hash-verified

30// The underlying algorithm is Meyers, its complexity is O(N*d) where N is
31// min(lines(src), lines(dst)) and d is the size of the diff.
32func DoWithTimeout(src, dst string, timeout time.Duration) (diffs []diffmatchpatch.Diff) {
33 dmp := diffmatchpatch.New()
34 dmp.DiffTimeout = timeout
35 wSrc, wDst, warray := dmp.DiffLinesToRunes(src, dst)
36 diffs = dmp.DiffMainRunes(wSrc, wDst, false)
37 diffs = dmp.DiffCharsToLines(diffs, warray)
38 return diffs
39}
40
41// Dst computes and returns the destination text.
42func Dst(diffs []diffmatchpatch.Diff) string {

Callers 1

DoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…