commonSuffixBytes returns the length in bytes of the common suffix of two strings, never splitting a rune.
(text1, text2 string)
| 462 | |
| 463 | // commonSuffixBytes returns the length in bytes of the common suffix of two strings, never splitting a rune. |
| 464 | func commonSuffixBytes(text1, text2 string) int { |
| 465 | n := 0 |
| 466 | for n < len(text1) && n < len(text2) { |
| 467 | _, size := utf8.DecodeLastRuneInString(text1[:len(text1)-n]) |
| 468 | if size > len(text2)-n || text1[len(text1)-n-size:len(text1)-n] != text2[len(text2)-n-size:len(text2)-n] { |
| 469 | break |
| 470 | } |
| 471 | n += size |
| 472 | } |
| 473 | return n |
| 474 | } |
| 475 | |
| 476 | // DiffCommonOverlap determines if the suffix of one string is the prefix of another. |
| 477 | func (dmp *DiffMatchPatch) DiffCommonOverlap(text1 string, text2 string) int { |
no outgoing calls
no test coverage detected