@@ -392,13 +392,13 @@ func (dmp *DiffMatchPatch) diffBisectSplit(runes1, runes2 []rune, x, y int,
392
392
// 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.
393
393
// It's slightly faster to call DiffLinesToRunes first, followed by DiffMainRunes.
394
394
func (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
397
397
}
398
398
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.
400
400
func (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 )
402
402
return []rune (chars1 ), []rune (chars2 ), lineArray
403
403
}
404
404
@@ -1308,8 +1308,8 @@ func (dmp *DiffMatchPatch) DiffFromDelta(text1 string, delta string) (diffs []Di
1308
1308
return diffs , nil
1309
1309
}
1310
1310
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 ) {
1313
1313
// '\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.
1314
1314
lineArray := []string {"" } // e.g. lineArray[4] == 'Hello\n'
1315
1315
@@ -1324,14 +1324,13 @@ func (dmp *DiffMatchPatch) DiffLinesToStrings(text1, text2 string) (string, stri
1324
1324
return str1 , str2 , lineArray
1325
1325
}
1326
1326
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.
1329
1328
func (dmp * DiffMatchPatch ) diffLinesToStringsMunge (text string , lineArray * []string ) []string {
1330
1329
// 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.
1331
1330
lineHash := map [string ]int {} // e.g. lineHash['Hello\n'] == 4
1332
1331
lineStart := 0
1333
1332
lineEnd := - 1
1334
- strings := []string {}
1333
+ strs := []string {}
1335
1334
1336
1335
for lineEnd < len (text )- 1 {
1337
1336
lineEnd = indexOf (text , "\n " , lineStart )
@@ -1345,13 +1344,13 @@ func (dmp *DiffMatchPatch) diffLinesToStringsMunge(text string, lineArray *[]str
1345
1344
lineValue , ok := lineHash [line ]
1346
1345
1347
1346
if ok {
1348
- strings = append (strings , strconv .Itoa (lineValue ))
1347
+ strs = append (strs , strconv .Itoa (lineValue ))
1349
1348
} else {
1350
1349
* lineArray = append (* lineArray , line )
1351
1350
lineHash [line ] = len (* lineArray ) - 1
1352
- strings = append (strings , strconv .Itoa (len (* lineArray )- 1 ))
1351
+ strs = append (strs , strconv .Itoa (len (* lineArray )- 1 ))
1353
1352
}
1354
1353
}
1355
1354
1356
- return strings
1355
+ return strs
1357
1356
}
0 commit comments