You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// DiffLinesToChars splits two texts into a list of strings. Reduces the texts to a string of
357
-
// hashes where each Unicode character represents one line.
349
+
// DiffLinesToChars splits two texts into a list of strings, and educes the texts to a string of hashes where each Unicode character represents one line.
358
350
// It's slightly faster to call DiffLinesToRunes first, followed by DiffMainRunes.
// Walk the text, pulling out a substring for each line.
386
-
// text.split('\n') would would temporarily double our memory footprint.
387
-
// Modifying text would create many large strings to garbage collect.
375
+
// Walk the text, pulling out a substring for each line. text.split('\n') would would temporarily double our memory footprint. Modifying text would create many large strings to garbage collect.
// Start by looking for a single character match and increase length until no match is found. Performance analysis: http://neil.fraser.name/news/2010/11/04/
// DiffHalfMatch checks whether the two texts share a substring which is at
534
-
// least half the length of the longer text. This speedup can produce non-minimal diffs.
518
+
// 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.
// diffHalfMatchI checks if a substring of shorttext exist within longtext such that the substring is at least half the length of longtext?
599
-
// @param {string} longtext Longer string.
600
-
// @param {string} shorttext Shorter string.
601
-
// @param {number} i Start index of quarter length substring within longtext.
602
-
// @return {Array.<string>} Five element Array, containing the prefix of
603
-
// longtext, the suffix of longtext, the prefix of shorttext, the suffix
604
-
// of shorttext and the common middle. Or null if there was no match.
583
+
// Returns a slice containing the prefix of longtext, the suffix of longtext, the prefix of shorttext, the suffix of shorttext and the common middle, or null if there was no match.
605
584
func (dmp*DiffMatchPatch) diffHalfMatchI(l, s []rune, iint) [][]rune {
606
585
varbestCommonA []rune
607
586
varbestCommonB []rune
@@ -642,8 +621,7 @@ func (dmp *DiffMatchPatch) diffHalfMatchI(l, s []rune, i int) [][]rune {
642
621
}
643
622
}
644
623
645
-
// DiffCleanupSemantic reduces the number of edits by eliminating
646
-
// semantically trivial equalities.
624
+
// DiffCleanupSemantic reduces the number of edits by eliminating semantically trivial equalities.
// diffCleanupSemanticScore computes a score representing whether the internal boundary falls on logical boundaries. Scores range from 6 (best) to 0 (worst). Closure, but does not reference any external variables.
766
+
// diffCleanupSemanticScore computes a score representing whether the internal boundary falls on logical boundaries.
767
+
// Scores range from 6 (best) to 0 (worst). Closure, but does not reference any external variables.
789
768
funcdiffCleanupSemanticScore(one, twostring) int {
790
769
iflen(one) ==0||len(two) ==0 {
791
770
// Edges are the best.
792
771
return6
793
772
}
794
773
795
-
// Each port of this function behaves slightly differently due to
796
-
// subtle differences in each language's definition of things like
797
-
// 'whitespace'. Since this function's purpose is largely cosmetic,
798
-
// the choice has been made to use each language's native features
799
-
// rather than force total conformity.
774
+
// Each port of this function behaves slightly differently due to subtle differences in each language's definition of things like 'whitespace'. Since this function's purpose is largely cosmetic, the choice has been made to use each language's native features rather than force total conformity.
800
775
rune1, _:=utf8.DecodeLastRuneInString(one)
801
776
rune2, _:=utf8.DecodeRuneInString(two)
802
777
char1:=string(rune1)
@@ -830,9 +805,8 @@ func diffCleanupSemanticScore(one, two string) int {
830
805
return0
831
806
}
832
807
833
-
// DiffCleanupSemanticLossless looks for single edits surrounded on both sides by equalities
834
-
// which can be shifted sideways to align the edit to a word boundary.
835
-
// e.g: The c<ins>at c</ins>ame. -> The <ins>cat </ins>came.
808
+
// DiffCleanupSemanticLossless looks for single edits surrounded on both sides by equalities which can be shifted sideways to align the edit to a word boundary.
809
+
// E.g: The c<ins>at c</ins>ame. -> The <ins>cat </ins>came.
diffs=diffs[0 : len(diffs)-1] // Remove the dummy entry at the end.
1113
1084
}
1114
1085
1115
-
// Second pass: look for single edits surrounded on both sides by
1116
-
// equalities which can be shifted sideways to eliminate an equality.
1117
-
// e.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
1086
+
// Second pass: look for single edits surrounded on both sides by equalities which can be shifted sideways to eliminate an equality. E.g: A<ins>BA</ins>C -> <ins>AB</ins>AC
1118
1087
changes:=false
1119
1088
pointer=1
1120
1089
// Intentionally ignore the first and last element (don't need checking).
// DiffFromDelta given the original text1, and an encoded string which describes the
1322
-
// operations required to transform text1 into text2, comAdde the full diff.
1282
+
// DiffFromDelta given the original text1, and an encoded string which describes the operations required to transform text1 into text2, comAdde the full diff.
0 commit comments