@@ -392,13 +392,13 @@ func (dmp *DiffMatchPatch) diffBisectSplit(runes1, runes2 []rune, x, y int,
392392// 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.
393393// It's slightly faster to call DiffLinesToRunes first, followed by DiffMainRunes.
394394func (dmp * DiffMatchPatch ) DiffLinesToChars (text1 , text2 string ) (string , string , []string ) {
395- chars1 , chars2 , lineArray := dmp .DiffLinesToRunes (text1 , text2 )
396- return string ( chars1 ), string ( chars2 ) , lineArray
395+ chars1 , chars2 , lineArray := dmp .diffLinesToStrings (text1 , text2 )
396+ return chars1 , chars2 , lineArray
397397}
398398
399- // DiffLinesToRunes splits two texts into a list of runes. Each rune represents one line.
399+ // DiffLinesToRunes splits two texts into a list of runes.
400400func (dmp * DiffMatchPatch ) DiffLinesToRunes (text1 , text2 string ) ([]rune , []rune , []string ) {
401- chars1 , chars2 , lineArray := dmp .DiffLinesToStrings (text1 , text2 )
401+ chars1 , chars2 , lineArray := dmp .diffLinesToStrings (text1 , text2 )
402402 return []rune (chars1 ), []rune (chars2 ), lineArray
403403}
404404
@@ -1308,8 +1308,8 @@ func (dmp *DiffMatchPatch) DiffFromDelta(text1 string, delta string) (diffs []Di
13081308 return diffs , nil
13091309}
13101310
1311- // DiffLinesToStrings splits two texts into a list of strings. Each string represents one line.
1312- func (dmp * DiffMatchPatch ) DiffLinesToStrings (text1 , text2 string ) (string , string , []string ) {
1311+ // diffLinesToStrings splits two texts into a list of strings. Each string represents one line.
1312+ func (dmp * DiffMatchPatch ) diffLinesToStrings (text1 , text2 string ) (string , string , []string ) {
13131313 // '\x00' is a valid character, but various debuggers don't like it. So we'll insert a junk entry to avoid generating a null character.
13141314 lineArray := []string {"" } // e.g. lineArray[4] == 'Hello\n'
13151315
@@ -1324,14 +1324,13 @@ func (dmp *DiffMatchPatch) DiffLinesToStrings(text1, text2 string) (string, stri
13241324 return str1 , str2 , lineArray
13251325}
13261326
1327- // diffLinesToStringsMunge splits a text into an array of strings, and reduces the texts to a []rune where each Unicode character represents one line.
1328- // We use strings instead of []runes as input mainly because you can't use []rune as a map key.
1327+ // diffLinesToStringsMunge splits a text into an array of strings, and reduces the texts to a []string.
13291328func (dmp * DiffMatchPatch ) diffLinesToStringsMunge (text string , lineArray * []string ) []string {
13301329 // 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.
13311330 lineHash := map [string ]int {} // e.g. lineHash['Hello\n'] == 4
13321331 lineStart := 0
13331332 lineEnd := - 1
1334- strings := []string {}
1333+ strs := []string {}
13351334
13361335 for lineEnd < len (text )- 1 {
13371336 lineEnd = indexOf (text , "\n " , lineStart )
@@ -1345,13 +1344,13 @@ func (dmp *DiffMatchPatch) diffLinesToStringsMunge(text string, lineArray *[]str
13451344 lineValue , ok := lineHash [line ]
13461345
13471346 if ok {
1348- strings = append (strings , strconv .Itoa (lineValue ))
1347+ strs = append (strs , strconv .Itoa (lineValue ))
13491348 } else {
13501349 * lineArray = append (* lineArray , line )
13511350 lineHash [line ] = len (* lineArray ) - 1
1352- strings = append (strings , strconv .Itoa (len (* lineArray )- 1 ))
1351+ strs = append (strs , strconv .Itoa (len (* lineArray )- 1 ))
13531352 }
13541353 }
13551354
1356- return strings
1355+ return strs
13571356}
0 commit comments