File tree 5 files changed +4142
-4244
lines changed
5 files changed +4142
-4244
lines changed Original file line number Diff line number Diff line change @@ -1446,9 +1446,9 @@ class DiffMatchPatch {
1446
1446
* Returns the best match index or -1.
1447
1447
*/
1448
1448
int _match_bitap (String text, String pattern, int loc) {
1449
- Expect . isTrue (Match_MaxBits == 0 || pattern.length <= Match_MaxBits ,
1450
- 'Pattern too long for this application.' );
1451
-
1449
+ if (Match_MaxBits != 0 && pattern.length > Match_MaxBits ) {
1450
+ throw new Exception ( 'Pattern too long for this application.' );
1451
+ }
1452
1452
// Initialise the alphabet.
1453
1453
Map <String , int > s = _match_alphabet (pattern);
1454
1454
@@ -1967,7 +1967,7 @@ class DiffMatchPatch {
1967
1967
}
1968
1968
while (! bigpatch.diffs.isEmpty &&
1969
1969
patch.length1 < patch_size - Patch_Margin ) {
1970
- int diff_type = bigpatch.diffs[0 ].operation;
1970
+ Operation diff_type = bigpatch.diffs[0 ].operation;
1971
1971
String diff_text = bigpatch.diffs[0 ].text;
1972
1972
if (diff_type == Operation .insert) {
1973
1973
// Insertions are harmless.
Original file line number Diff line number Diff line change 19
19
library DiffMatchPatch;
20
20
21
21
import 'dart:math' ;
22
+ import 'dart:collection' ;
22
23
23
24
part 'DMPClass.dart' ;
24
25
part 'DiffClass.dart' ;
Original file line number Diff line number Diff line change @@ -72,13 +72,13 @@ class Expect {
72
72
static void mapEquals (Map expected, Map actual, String msg) {
73
73
for (var k in actual.keys) {
74
74
if (! expected.containsKey (k)) {
75
- throw new Exception ('Expect.mapEquals(unexpected key <$key > found '
75
+ throw new Exception ('Expect.mapEquals(unexpected key <$k > found '
76
76
'expected: <$expected >, actual: <$actual > $msg ) fails' );
77
77
}
78
78
}
79
79
for (var k in expected.keys) {
80
80
if (! actual.containsKey (k)) {
81
- throw new Exception ('Expect.mapEquals(key <$key > not found '
81
+ throw new Exception ('Expect.mapEquals(key <$k > not found '
82
82
'expected: <$expected >, actual: <$actual > $msg ) fails' );
83
83
}
84
84
Expect .equals (actual[k], expected[k], "$msg [Key: $k ]" );
Original file line number Diff line number Diff line change @@ -5,8 +5,10 @@ import '../DiffMatchPatch.dart';
5
5
// dart2js --out=Speedtest.dart.js Speedtest.dart
6
6
7
7
void launch (Event e) {
8
- String text1 = document.query ('#text1' ).value;
9
- String text2 = document.query ('#text2' ).value;
8
+ HtmlElement input1 = document.getElementById ('text1' );
9
+ HtmlElement input2 = document.getElementById ('text2' );
10
+ String text1 = input1.text;
11
+ String text2 = input2.text;
10
12
11
13
DiffMatchPatch dmp = new DiffMatchPatch ();
12
14
dmp.Diff_Timeout = 0.0 ;
@@ -17,12 +19,11 @@ void launch(Event e) {
17
19
DateTime date_end = new DateTime .now ();
18
20
19
21
var ds = dmp.diff_prettyHtml (d);
20
- document.query ( '# outputdiv' ).setInnerHtml (
22
+ document.getElementById ( ' outputdiv' ).setInnerHtml (
21
23
'$ds <BR>Time: ${date_end .difference (date_start )} (h:mm:ss.mmm)' );
22
24
}
23
25
24
26
void main () {
25
- document.query ( '# launch' ).addEventListener ('click' , launch);
26
- document.query ( '# outputdiv' ).setInnerHtml ('' );
27
+ document.getElementById ( ' launch' ).addEventListener ('click' , launch);
28
+ document.getElementById ( ' outputdiv' ).setInnerHtml ('' );
27
29
}
28
-
You can’t perform that action at this time.
0 commit comments