1- /*Package difflib is a partial port of Python difflib module.
1+ /*
2+ Package difflib is a partial port of Python difflib module.
23
34Original source: https://github.com/pmezard/go-difflib
45
56This file is trimmed to only the parts used by this repository.
67*/
78package difflib // import "gotest.tools/v3/internal/difflib"
89
9- func min (a , b int ) int {
10+ func minInt (a , b int ) int {
1011 if a < b {
1112 return a
1213 }
1314 return b
1415}
1516
16- func max (a , b int ) int {
17+ func maxInt (a , b int ) int {
1718 if a > b {
1819 return a
1920 }
@@ -170,12 +171,15 @@ func (m *SequenceMatcher) isBJunk(s string) bool {
170171// If IsJunk is not defined:
171172//
172173// Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where
173- // alo <= i <= i+k <= ahi
174- // blo <= j <= j+k <= bhi
174+ //
175+ // alo <= i <= i+k <= ahi
176+ // blo <= j <= j+k <= bhi
177+ //
175178// and for all (i',j',k') meeting those conditions,
176- // k >= k'
177- // i <= i'
178- // and if i == i', j <= j'
179+ //
180+ // k >= k'
181+ // i <= i'
182+ // and if i == i', j <= j'
179183//
180184// In other words, of all maximal matching blocks, return one that
181185// starts earliest in a, and of all those maximal matching blocks that
@@ -393,12 +397,12 @@ func (m *SequenceMatcher) GetGroupedOpCodes(n int) [][]OpCode {
393397 if codes [0 ].Tag == 'e' {
394398 c := codes [0 ]
395399 i1 , i2 , j1 , j2 := c .I1 , c .I2 , c .J1 , c .J2
396- codes [0 ] = OpCode {c .Tag , max (i1 , i2 - n ), i2 , max (j1 , j2 - n ), j2 }
400+ codes [0 ] = OpCode {c .Tag , maxInt (i1 , i2 - n ), i2 , maxInt (j1 , j2 - n ), j2 }
397401 }
398402 if codes [len (codes )- 1 ].Tag == 'e' {
399403 c := codes [len (codes )- 1 ]
400404 i1 , i2 , j1 , j2 := c .I1 , c .I2 , c .J1 , c .J2
401- codes [len (codes )- 1 ] = OpCode {c .Tag , i1 , min (i2 , i1 + n ), j1 , min (j2 , j1 + n )}
405+ codes [len (codes )- 1 ] = OpCode {c .Tag , i1 , minInt (i2 , i1 + n ), j1 , minInt (j2 , j1 + n )}
402406 }
403407 nn := n + n
404408 groups := [][]OpCode {}
@@ -408,11 +412,11 @@ func (m *SequenceMatcher) GetGroupedOpCodes(n int) [][]OpCode {
408412 // End the current group and start a new one whenever
409413 // there is a large range with no changes.
410414 if c .Tag == 'e' && i2 - i1 > nn {
411- group = append (group , OpCode {c .Tag , i1 , min (i2 , i1 + n ),
412- j1 , min (j2 , j1 + n )})
415+ group = append (group , OpCode {c .Tag , i1 , minInt (i2 , i1 + n ),
416+ j1 , minInt (j2 , j1 + n )})
413417 groups = append (groups , group )
414418 group = []OpCode {}
415- i1 , j1 = max (i1 , i2 - n ), max (j1 , j2 - n )
419+ i1 , j1 = maxInt (i1 , i2 - n ), maxInt (j1 , j2 - n )
416420 }
417421 group = append (group , OpCode {c .Tag , i1 , i2 , j1 , j2 })
418422 }
0 commit comments