@@ -37,7 +37,6 @@ const (
37
37
DiffDelete = - 1
38
38
DiffInsert = 1
39
39
DiffEqual = 0
40
- max64 = int64 (uint64 (1 << 63 ) - 1 )
41
40
)
42
41
43
42
// unescaper unescapes selected chars for compatability with JavaScript's encodeURI.
@@ -199,24 +198,18 @@ func New() *DiffMatchPatch {
199
198
}
200
199
201
200
// DiffMain finds the differences between two texts.
202
- func (dmp * DiffMatchPatch ) DiffMain (text1 string , text2 string , opt ... interface {}) []Diff {
203
- checklines := true
201
+ func (dmp * DiffMatchPatch ) DiffMain (text1 , text2 string , checklines bool ) []Diff {
204
202
var deadline time.Time
205
-
206
- if opt != nil && len (opt ) > 0 {
207
- checklines = opt [0 ].(bool )
208
-
209
- if len (opt ) > 1 {
210
- deadline = opt [1 ].(time.Time )
211
- } else {
212
- if dmp .DiffTimeout <= 0 {
213
- deadline = time .Now ().Add (24 * 365 * time .Hour )
214
- } else {
215
- deadline = time .Now ().Add (dmp .DiffTimeout )
216
- }
217
- }
203
+ if dmp .DiffTimeout <= 0 {
204
+ deadline = time .Now ().Add (24 * 365 * time .Hour )
205
+ } else {
206
+ deadline = time .Now ().Add (dmp .DiffTimeout )
218
207
}
208
+ return dmp .diffMain (text1 , text2 , checklines , deadline )
209
+ }
219
210
211
+ // DiffMain finds the differences between two texts.
212
+ func (dmp * DiffMatchPatch ) diffMain (text1 , text2 string , checklines bool , deadline time.Time ) []Diff {
220
213
diffs := []Diff {}
221
214
if text1 == text2 {
222
215
if len (text1 ) > 0 {
@@ -303,8 +296,8 @@ checklines bool, deadline time.Time) []Diff {
303
296
text2_b := hm [3 ]
304
297
mid_common := hm [4 ]
305
298
// Send both pairs off for separate processing.
306
- diffs_a := dmp .DiffMain (text1_a , text2_a , checklines , deadline )
307
- diffs_b := dmp .DiffMain (text1_b , text2_b , checklines , deadline )
299
+ diffs_a := dmp .diffMain (text1_a , text2_a , checklines , deadline )
300
+ diffs_b := dmp .diffMain (text1_b , text2_b , checklines , deadline )
308
301
// Merge the results.
309
302
return append (diffs_a , append ([]Diff {Diff {DiffEqual , mid_common }}, diffs_b ... )... )
310
303
} else if checklines && utf8 .RuneCountInString (text1 ) > 100 && utf8 .RuneCountInString (text2 ) > 100 {
@@ -320,7 +313,7 @@ deadline time.Time) []Diff {
320
313
// Scan the text on a line-by-line basis first.
321
314
text1 , text2 , linearray := dmp .DiffLinesToChars (text1 , text2 )
322
315
323
- diffs := dmp .DiffMain (text1 , text2 , false , deadline )
316
+ diffs := dmp .diffMain (text1 , text2 , false , deadline )
324
317
325
318
// Convert the diff back to original text.
326
319
diffs = dmp .DiffCharsToLines (diffs , linearray )
@@ -353,7 +346,7 @@ deadline time.Time) []Diff {
353
346
count_delete + count_insert )
354
347
355
348
pointer = pointer - count_delete - count_insert
356
- a := dmp .DiffMain (text_delete , text_insert , false , deadline )
349
+ a := dmp .diffMain (text_delete , text_insert , false , deadline )
357
350
for j := len (a ) - 1 ; j >= 0 ; j -- {
358
351
diffs = splice (diffs , pointer , 0 , a [j ])
359
352
}
@@ -494,8 +487,8 @@ deadline time.Time) []Diff {
494
487
text2b := string (text2 [y :])
495
488
496
489
// Compute both diffs serially.
497
- diffs := dmp .DiffMain (text1a , text2a , false , deadline )
498
- diffsb := dmp .DiffMain (text1b , text2b , false , deadline )
490
+ diffs := dmp .diffMain (text1a , text2a , false , deadline )
491
+ diffsb := dmp .diffMain (text1b , text2b , false , deadline )
499
492
500
493
return append (diffs , diffsb ... )
501
494
}
0 commit comments