MCPcopy Create free account
hub / github.com/sergi/go-diff / DiffHalfMatch

Method DiffHalfMatch

diffmatchpatch/diff.go:517–529  ·  view source on GitHub ↗

DiffHalfMatch checks whether the two texts share a substring which is at least half the length of the longer text. This speedup can produce non-minimal diffs.

(text1, text2 string)

Source from the content-addressed store, hash-verified

515
516// DiffHalfMatch checks whether the two texts share a substring which is at least half the length of the longer text. This speedup can produce non-minimal diffs.
517func (dmp *DiffMatchPatch) DiffHalfMatch(text1, text2 string) []string {
518 // Unused in this code, but retained for interface compatibility.
519 runeSlices := dmp.diffHalfMatch([]rune(text1), []rune(text2))
520 if runeSlices == nil {
521 return nil
522 }
523
524 result := make([]string, len(runeSlices))
525 for i, r := range runeSlices {
526 result[i] = string(r)
527 }
528 return result
529}
530
531func (dmp *DiffMatchPatch) diffHalfMatch(text1, text2 []rune) [][]rune {
532 if dmp.DiffTimeout <= 0 {

Callers 2

TestDiffHalfMatchFunction · 0.80
BenchmarkDiffHalfMatchFunction · 0.80

Calls 1

diffHalfMatchMethod · 0.95

Tested by 2

TestDiffHalfMatchFunction · 0.64
BenchmarkDiffHalfMatchFunction · 0.64