@@ -195,7 +195,7 @@ func (dmp *DiffMatchPatch) diffCompute(text1, text2 []rune, checklines bool, dea
195
195
// diffLineMode does a quick line-level diff on both []runes, then rediff the parts for greater accuracy. This speedup can produce non-minimal diffs.
196
196
func (dmp * DiffMatchPatch ) diffLineMode (text1 , text2 []rune , deadline time.Time ) []Diff {
197
197
// Scan the text on a line-by-line basis first.
198
- text1 , text2 , linearray := dmp .diffLinesToRunes ( text1 , text2 )
198
+ text1 , text2 , linearray := dmp .DiffLinesToRunes ( string ( text1 ), string ( text2 ) )
199
199
200
200
diffs := dmp .diffMainRunes (text1 , text2 , false , deadline )
201
201
@@ -402,13 +402,23 @@ func (dmp *DiffMatchPatch) DiffLinesToRunes(text1, text2 string) ([]rune, []rune
402
402
return []rune (chars1 ), []rune (chars2 ), lineArray
403
403
}
404
404
405
- func (dmp * DiffMatchPatch ) diffLinesToRunes (text1 , text2 []rune ) ([]rune , []rune , []string ) {
406
- return dmp .DiffLinesToRunes (string (text1 ), string (text2 ))
407
- }
408
-
409
405
// DiffCharsToLines rehydrates the text in a diff from a string of line hashes to real lines of text.
410
406
func (dmp * DiffMatchPatch ) DiffCharsToLines (diffs []Diff , lineArray []string ) []Diff {
411
- hydrated := dmp .DiffStringsToLines (diffs , lineArray )
407
+ hydrated := make ([]Diff , 0 , len (diffs ))
408
+ for _ , aDiff := range diffs {
409
+ chars := strings .Split (aDiff .Text , IndexSeperator )
410
+ text := make ([]string , len (chars ))
411
+
412
+ for i , r := range chars {
413
+ i1 , err := strconv .Atoi (r )
414
+ if err == nil {
415
+ text [i ] = lineArray [i1 ]
416
+ }
417
+ }
418
+
419
+ aDiff .Text = strings .Join (text , "" )
420
+ hydrated = append (hydrated , aDiff )
421
+ }
412
422
return hydrated
413
423
}
414
424
@@ -1345,23 +1355,3 @@ func (dmp *DiffMatchPatch) diffLinesToStringsMunge(text string, lineArray *[]str
1345
1355
1346
1356
return strings
1347
1357
}
1348
-
1349
- // DiffStringsToLines rehydrates the text in a diff from a string of line hashes to real lines of text.
1350
- func (dmp * DiffMatchPatch ) DiffStringsToLines (diffs []Diff , lineArray []string ) []Diff {
1351
- hydrated := make ([]Diff , 0 , len (diffs ))
1352
- for _ , aDiff := range diffs {
1353
- chars := strings .Split (aDiff .Text , IndexSeperator )
1354
- text := make ([]string , len (chars ))
1355
-
1356
- for i , r := range chars {
1357
- i1 , err := strconv .Atoi (r )
1358
- if err == nil {
1359
- text [i ] = lineArray [i1 ]
1360
- }
1361
- }
1362
-
1363
- aDiff .Text = strings .Join (text , "" )
1364
- hydrated = append (hydrated , aDiff )
1365
- }
1366
- return hydrated
1367
- }
0 commit comments