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

Method DiffHalfMatch

diffmatchpatch/diff.go:500–512  ·  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

498
499// 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.
500func (dmp *DiffMatchPatch) DiffHalfMatch(text1, text2 string) []string {
501 // Unused in this code, but retained for interface compatibility.
502 runeSlices := dmp.diffHalfMatch([]rune(text1), []rune(text2))
503 if runeSlices == nil {
504 return nil
505 }
506
507 result := make([]string, len(runeSlices))
508 for i, r := range runeSlices {
509 result[i] = string(r)
510 }
511 return result
512}
513
514func (dmp *DiffMatchPatch) diffHalfMatch(text1, text2 []rune) [][]rune {
515 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