commonSuffixLength returns the length of the common suffix of two rune slices.
(text1, text2 []rune)
| 443 | |
| 444 | // commonSuffixLength returns the length of the common suffix of two rune slices. |
| 445 | func commonSuffixLength(text1, text2 []rune) int { |
| 446 | // Use linear search rather than the binary search discussed at https://neil.fraser.name/news/2007/10/09/. |
| 447 | // See discussion at https://github.com/sergi/go-diff/issues/54. |
| 448 | i1 := len(text1) |
| 449 | i2 := len(text2) |
| 450 | for n := 0; ; n++ { |
| 451 | i1-- |
| 452 | i2-- |
| 453 | if i1 < 0 || i2 < 0 || text1[i1] != text2[i2] { |
| 454 | return n |
| 455 | } |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | // DiffCommonOverlap determines if the suffix of one string is the prefix of another. |
| 460 | func (dmp *DiffMatchPatch) DiffCommonOverlap(text1 string, text2 string) int { |
no outgoing calls
searching dependent graphs…