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)
| 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. |
| 517 | func (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 | |
| 531 | func (dmp *DiffMatchPatch) diffHalfMatch(text1, text2 []rune) [][]rune { |
| 532 | if dmp.DiffTimeout <= 0 { |