(text1, text2 []rune, checklines bool, deadline time.Time)
| 96 | } |
| 97 | |
| 98 | func (dmp *DiffMatchPatch) diffMainRunes(text1, text2 []rune, checklines bool, deadline time.Time) []Diff { |
| 99 | if runesEqual(text1, text2) { |
| 100 | var diffs []Diff |
| 101 | if len(text1) > 0 { |
| 102 | diffs = append(diffs, Diff{DiffEqual, string(text1)}) |
| 103 | } |
| 104 | return diffs |
| 105 | } |
| 106 | // Trim off common prefix (speedup). |
| 107 | commonlength := commonPrefixLength(text1, text2) |
| 108 | commonprefix := text1[:commonlength] |
| 109 | text1 = text1[commonlength:] |
| 110 | text2 = text2[commonlength:] |
| 111 | |
| 112 | // Trim off common suffix (speedup). |
| 113 | commonlength = commonSuffixLength(text1, text2) |
| 114 | commonsuffix := text1[len(text1)-commonlength:] |
| 115 | text1 = text1[:len(text1)-commonlength] |
| 116 | text2 = text2[:len(text2)-commonlength] |
| 117 | |
| 118 | // Compute the diff on the middle block. |
| 119 | diffs := dmp.diffCompute(text1, text2, checklines, deadline) |
| 120 | |
| 121 | // Restore the prefix and suffix. |
| 122 | if len(commonprefix) != 0 { |
| 123 | diffs = append([]Diff{{DiffEqual, string(commonprefix)}}, diffs...) |
| 124 | } |
| 125 | if len(commonsuffix) != 0 { |
| 126 | diffs = append(diffs, Diff{DiffEqual, string(commonsuffix)}) |
| 127 | } |
| 128 | |
| 129 | return dmp.DiffCleanupMerge(diffs) |
| 130 | } |
| 131 | |
| 132 | // diffCompute finds the differences between two rune slices. Assumes that the texts do not have any common prefix or suffix. |
| 133 | func (dmp *DiffMatchPatch) diffCompute(text1, text2 []rune, checklines bool, deadline time.Time) []Diff { |
no test coverage detected