| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library fasta.scanner.abstract_scanner; | 5 library fasta.scanner.abstract_scanner; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 | 8 |
| 9 class Node { | 9 class Node { |
| 10 var /* String | List<int> */ data; | 10 var /* String | List<int> */ data; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 /// Mask away top bits to keep hash calculation within 32-bit SMI range. | 27 /// Mask away top bits to keep hash calculation within 32-bit SMI range. |
| 28 static const int MASK = 16 * 1024 * 1024 - 1; | 28 static const int MASK = 16 * 1024 * 1024 - 1; |
| 29 | 29 |
| 30 static const int INITIAL_SIZE = 8 * 1024; | 30 static const int INITIAL_SIZE = 8 * 1024; |
| 31 | 31 |
| 32 /// Linear size of a hash table. | 32 /// Linear size of a hash table. |
| 33 int _size = INITIAL_SIZE; | 33 int _size = INITIAL_SIZE; |
| 34 /// Items in a hash table. | 34 /// Items in a hash table. |
| 35 int _count = 0; | 35 int _count = 0; |
| 36 /// The table itself. | 36 /// The table itself. |
| 37 Node _nodes = new List<Node>(INITIAL_SIZE); | 37 List<Node> _nodes = new List<Node>(INITIAL_SIZE); |
| 38 | 38 |
| 39 static String decode(List<int> data, int start, int end, bool asciiOnly) { | 39 static String decode(List<int> data, int start, int end, bool asciiOnly) { |
| 40 var s; | 40 var s; |
| 41 if (asciiOnly) { | 41 if (asciiOnly) { |
| 42 s = new String.fromCharCodes(data, start, end); | 42 s = new String.fromCharCodes(data, start, end); |
| 43 } else { | 43 } else { |
| 44 s = new Utf8Decoder(allowMalformed: true).convert(data, start, end); | 44 s = new Utf8Decoder(allowMalformed: true).convert(data, start, end); |
| 45 } | 45 } |
| 46 return s; | 46 return s; |
| 47 } | 47 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 payload = decode(data, start, end, asciiOnly); | 109 payload = decode(data, start, end, asciiOnly); |
| 110 _nodes[index] = new Node(data, start, end, payload, s); | 110 _nodes[index] = new Node(data, start, end, payload, s); |
| 111 _count++; | 111 _count++; |
| 112 return payload; | 112 return payload; |
| 113 } | 113 } |
| 114 | 114 |
| 115 clear() { | 115 clear() { |
| 116 _nodes = new List<Node>(_size); | 116 _nodes = new List<Node>(_size); |
| 117 } | 117 } |
| 118 } | 118 } |
| OLD | NEW |