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