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