Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Side by Side Diff: packages/html/lib/src/tokenizer.dart

Issue 2990843002: Removed fixed dependencies (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « packages/html/lib/src/query_selector.dart ('k') | packages/html/lib/src/treebuilder.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 library tokenizer; 1 library tokenizer;
2 2
3 import 'dart:collection'; 3 import 'dart:collection';
4 import 'package:html/parser.dart' show HtmlParser; 4 import 'package:html/parser.dart' show HtmlParser;
5 import 'constants.dart'; 5 import 'constants.dart';
6 import 'inputstream.dart'; 6 import 'inputstream.dart';
7 import 'token.dart'; 7 import 'token.dart';
8 import 'utils.dart'; 8 import 'utils.dart';
9 9
10 // Group entities by their first character, for faster lookups 10 // Group entities by their first character, for faster lookups
11 11
12 // TODO(jmesserly): we could use a better data structure here like a trie, if 12 // TODO(jmesserly): we could use a better data structure here like a trie, if
13 // we had it implemented in Dart. 13 // we had it implemented in Dart.
14 Map<String, List<String>> entitiesByFirstChar = (() { 14 Map<String, List<String>> entitiesByFirstChar = (() {
15 var result = {}; 15 var result = <String, List<String>>{};
16 for (var k in entities.keys) { 16 for (var k in entities.keys) {
17 result.putIfAbsent(k[0], () => []).add(k); 17 result.putIfAbsent(k[0], () => []).add(k);
18 } 18 }
19 return result; 19 return result;
20 })(); 20 })();
21 21
22 // TODO(jmesserly): lots of ways to make this faster: 22 // TODO(jmesserly): lots of ways to make this faster:
23 // - use char codes everywhere instead of 1-char strings 23 // - use char codes everywhere instead of 1-char strings
24 // - use switch instead of contains, indexOf 24 // - use switch instead of contains, indexOf
25 // - use switch instead of the sequential if tests 25 // - use switch instead of the sequential if tests
(...skipping 1873 matching lines...) Expand 10 before | Expand all | Expand 10 after
1899 } 1899 }
1900 } 1900 }
1901 1901
1902 if (data.length > 0) { 1902 if (data.length > 0) {
1903 _addToken(new CharactersToken(data.join())); 1903 _addToken(new CharactersToken(data.join()));
1904 } 1904 }
1905 state = dataState; 1905 state = dataState;
1906 return true; 1906 return true;
1907 } 1907 }
1908 } 1908 }
OLDNEW
« no previous file with comments | « packages/html/lib/src/query_selector.dart ('k') | packages/html/lib/src/treebuilder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698