Skip to content

Commit 6b65b52

Browse files
committed
rebased on upstream/master
1 parent b94bf77 commit 6b65b52

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

diffmatchpatch/dmp.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ func (dmp *DiffMatchPatch) DiffBisect(text1, text2 string, deadline time.Time) [
421421
// diffBisect finds the 'middle snake' of a diff, splits the problem in two
422422
// and returns the recursively constructed diff.
423423
// See Myers's 1986 paper: An O(ND) Difference Algorithm and Its Variations.
424-
func (dmp *DiffMatchPatch) diffBisect(text1, text2 []rune, deadline time.Time) []Diff {
424+
func (dmp *DiffMatchPatch) diffBisect(runes1, runes2 []rune, deadline time.Time) []Diff {
425425
// Cache the text lengths to prevent multiple calls.
426426
runes1_len, runes2_len := len(runes1), len(runes2)
427427

@@ -466,8 +466,8 @@ func (dmp *DiffMatchPatch) diffBisect(text1, text2 []rune, deadline time.Time) [
466466
}
467467

468468
y1 := x1 - k1
469-
for x1 < text1_len && y1 < text2_len {
470-
if text1[x1] != text2[y1] {
469+
for x1 < runes1_len && y1 < runes2_len {
470+
if runes1[x1] != runes2[y1] {
471471
break
472472
}
473473
x1++
@@ -502,8 +502,8 @@ func (dmp *DiffMatchPatch) diffBisect(text1, text2 []rune, deadline time.Time) [
502502
x2 = v2[k2_offset-1] + 1
503503
}
504504
var y2 = x2 - k2
505-
for x2 < text1_len && y2 < text2_len {
506-
if text1[text1_len-x2-1] != text2[text2_len-y2-1] {
505+
for x2 < runes1_len && y2 < runes2_len {
506+
if runes1[runes1_len-x2-1] != runes2[runes2_len-y2-1] {
507507
break
508508
}
509509
x2++
@@ -534,21 +534,21 @@ func (dmp *DiffMatchPatch) diffBisect(text1, text2 []rune, deadline time.Time) [
534534
// Diff took too long and hit the deadline or
535535
// number of diffs equals number of characters, no commonality at all.
536536
return []Diff{
537-
Diff{DiffDelete, string(text1)},
538-
Diff{DiffInsert, string(text2)},
537+
Diff{DiffDelete, string(runes1)},
538+
Diff{DiffInsert, string(runes2)},
539539
}
540540
}
541541

542-
func (dmp *DiffMatchPatch) diffBisectSplit_(text1, text2 []rune, x, y int,
542+
func (dmp *DiffMatchPatch) diffBisectSplit_(runes1, runes2 []rune, x, y int,
543543
deadline time.Time) []Diff {
544544
runes1a := runes1[:x]
545545
runes2a := runes2[:y]
546546
runes1b := runes1[x:]
547547
runes2b := runes2[y:]
548548

549549
// Compute both diffs serially.
550-
diffs := dmp.diffMainRunes(text1a, text2a, false, deadline)
551-
diffsb := dmp.diffMainRunes(text1b, text2b, false, deadline)
550+
diffs := dmp.diffMainRunes(runes1a, runes2a, false, deadline)
551+
diffsb := dmp.diffMainRunes(runes1b, runes2b, false, deadline)
552552

553553
return append(diffs, diffsb...)
554554
}

0 commit comments

Comments
 (0)