Skip to content

Commit 90272a3

Browse files
committed
Update to Dart 2.20
Note that the dart2js speedtest just crashed from 1.6s to 25s. No change in the dart VM speedtest. Also, the unit tests currently don’t run due to stricter package rules (however, if the packages are hacked, the unit tests all pass).
1 parent 4c0c310 commit 90272a3

File tree

5 files changed

+4142
-4244
lines changed

5 files changed

+4142
-4244
lines changed

dart/DMPClass.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -1446,9 +1446,9 @@ class DiffMatchPatch {
14461446
* Returns the best match index or -1.
14471447
*/
14481448
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+
}
14521452
// Initialise the alphabet.
14531453
Map<String, int> s = _match_alphabet(pattern);
14541454

@@ -1967,7 +1967,7 @@ class DiffMatchPatch {
19671967
}
19681968
while (!bigpatch.diffs.isEmpty &&
19691969
patch.length1 < patch_size - Patch_Margin) {
1970-
int diff_type = bigpatch.diffs[0].operation;
1970+
Operation diff_type = bigpatch.diffs[0].operation;
19711971
String diff_text = bigpatch.diffs[0].text;
19721972
if (diff_type == Operation.insert) {
19731973
// Insertions are harmless.

dart/DiffMatchPatch.dart

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
library DiffMatchPatch;
2020

2121
import 'dart:math';
22+
import 'dart:collection';
2223

2324
part 'DMPClass.dart';
2425
part 'DiffClass.dart';

dart/tests/DiffMatchPatchTest.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ class Expect {
7272
static void mapEquals(Map expected, Map actual, String msg) {
7373
for (var k in actual.keys) {
7474
if (!expected.containsKey(k)) {
75-
throw new Exception('Expect.mapEquals(unexpected key <$key> found '
75+
throw new Exception('Expect.mapEquals(unexpected key <$k> found '
7676
'expected: <$expected>, actual: <$actual> $msg) fails');
7777
}
7878
}
7979
for (var k in expected.keys) {
8080
if (!actual.containsKey(k)) {
81-
throw new Exception('Expect.mapEquals(key <$key> not found '
81+
throw new Exception('Expect.mapEquals(key <$k> not found '
8282
'expected: <$expected>, actual: <$actual> $msg) fails');
8383
}
8484
Expect.equals(actual[k], expected[k], "$msg [Key: $k]");

dart/tests/Speedtest.dart

+7-6
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import '../DiffMatchPatch.dart';
55
// dart2js --out=Speedtest.dart.js Speedtest.dart
66

77
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;
1012

1113
DiffMatchPatch dmp = new DiffMatchPatch();
1214
dmp.Diff_Timeout = 0.0;
@@ -17,12 +19,11 @@ void launch(Event e) {
1719
DateTime date_end = new DateTime.now();
1820

1921
var ds = dmp.diff_prettyHtml(d);
20-
document.query('#outputdiv').setInnerHtml(
22+
document.getElementById('outputdiv').setInnerHtml(
2123
'$ds<BR>Time: ${date_end.difference(date_start)} (h:mm:ss.mmm)');
2224
}
2325

2426
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('');
2729
}
28-

0 commit comments

Comments
 (0)