OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Defines [LookupMap], a simple map that can be optimized by dart2js. | 5 /// Defines [LookupMap], a simple map that can be optimized by dart2js. |
6 library lookup_map; | 6 library lookup_map; |
7 | 7 |
8 /// [LookupMap] is a simple, but very restricted map. The map can only hold | 8 /// [LookupMap] is a simple, but very restricted map. The map can only hold |
9 /// constant keys and the only way to use the map is to retrieve values with a | 9 /// constant keys and the only way to use the map is to retrieve values with a |
10 /// key you already have. Expect for lookup, any other operation in [Map] (like | 10 /// key you already have. Except for lookup, any other operation in [Map] (like |
11 /// forEach, keys, values, length, etc) is not available. | 11 /// forEach, keys, values, length, etc) is not available. |
12 /// | 12 /// |
13 /// Constant [LookupMap]s are understood by dart2js and can be tree-shaken | 13 /// Constant [LookupMap]s are understood by dart2js and can be tree-shaken |
14 /// internally: if a key is not used elsewhere in the program, its entry can be | 14 /// internally: if a key is not used elsewhere in the program, its entry can be |
15 /// deleted from the map during compilation without changing the program's | 15 /// deleted from the map during compilation without changing the program's |
16 /// behavior. Currently dart2js supports tree-shaking keys that are `Type` | 16 /// behavior. Currently dart2js supports tree-shaking keys that are `Type` |
17 /// literals, and any const expression that can only be created with a const | 17 /// literals, and any const expression that can only be created with a const |
18 /// constructor. This means that primitives, Strings, and constant objects that | 18 /// constructor. This means that primitives, Strings, and constant objects that |
19 /// override the `==` operator cannot be tree-shaken. | 19 /// override the `==` operator cannot be tree-shaken. |
20 /// | 20 /// |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 /// An expando that stores a flatten version of a [LookupMap], this is | 91 /// An expando that stores a flatten version of a [LookupMap], this is |
92 /// computed and stored the first time the map is accessed. | 92 /// computed and stored the first time the map is accessed. |
93 final _flatMap = new Expando('_flat_map'); | 93 final _flatMap = new Expando('_flat_map'); |
94 | 94 |
95 /// Internal constant that matches the version in the pubspec. This is used by | 95 /// Internal constant that matches the version in the pubspec. This is used by |
96 /// dart2js to ensure that optimizations are only enabled on known versions of | 96 /// dart2js to ensure that optimizations are only enabled on known versions of |
97 /// this code. | 97 /// this code. |
98 // Note: this needs to be kept in sync with the pubspec, otherwise | 98 // Note: this needs to be kept in sync with the pubspec, otherwise |
99 // test/version_check_test would fail. | 99 // test/version_check_test would fail. |
100 final _version = '0.0.1'; | 100 final _version = '0.0.1+1'; |
OLD | NEW |