| 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 /// Analysis to determine how to generate code for `LookupMap`s. | 5 /// Analysis to determine how to generate code for `LookupMap`s. |
| 6 library compiler.src.js_backend.lookup_map_analysis; | 6 library compiler.src.js_backend.lookup_map_analysis; |
| 7 | 7 |
| 8 import 'package:pub_semver/pub_semver.dart'; | 8 import 'package:pub_semver/pub_semver.dart'; |
| 9 | 9 |
| 10 import '../common.dart'; | 10 import '../common.dart'; |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 301 |
| 302 // When --verbose is passed, we show the total number and set of keys that | 302 // When --verbose is passed, we show the total number and set of keys that |
| 303 // were tree-shaken from lookup maps. | 303 // were tree-shaken from lookup maps. |
| 304 Compiler compiler = backend.compiler; | 304 Compiler compiler = backend.compiler; |
| 305 if (compiler.options.verbose) { | 305 if (compiler.options.verbose) { |
| 306 var sb = new StringBuffer(); | 306 var sb = new StringBuffer(); |
| 307 int count = 0; | 307 int count = 0; |
| 308 for (var info in _lookupMaps.values) { | 308 for (var info in _lookupMaps.values) { |
| 309 for (var key in info.unusedEntries.keys) { | 309 for (var key in info.unusedEntries.keys) { |
| 310 if (count != 0) sb.write(','); | 310 if (count != 0) sb.write(','); |
| 311 sb.write(key.unparse()); | 311 sb.write(key.toDartText()); |
| 312 count++; | 312 count++; |
| 313 } | 313 } |
| 314 } | 314 } |
| 315 reporter.log(count == 0 | 315 reporter.log(count == 0 |
| 316 ? 'lookup-map: nothing was tree-shaken' | 316 ? 'lookup-map: nothing was tree-shaken' |
| 317 : 'lookup-map: found $count unused keys ($sb)'); | 317 : 'lookup-map: found $count unused keys ($sb)'); |
| 318 } | 318 } |
| 319 | 319 |
| 320 // Release resources. | 320 // Release resources. |
| 321 _lookupMaps.clear(); | 321 _lookupMaps.clear(); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 original.fields[analysis.valueField] = keyValuePairs[1]; | 429 original.fields[analysis.valueField] = keyValuePairs[1]; |
| 430 } | 430 } |
| 431 } else { | 431 } else { |
| 432 original.fields[analysis.entriesField] = | 432 original.fields[analysis.entriesField] = |
| 433 new ListConstantValue(listType, keyValuePairs); | 433 new ListConstantValue(listType, keyValuePairs); |
| 434 } | 434 } |
| 435 } | 435 } |
| 436 } | 436 } |
| 437 | 437 |
| 438 final _validLookupMapVersionConstraint = new VersionConstraint.parse('^0.0.1'); | 438 final _validLookupMapVersionConstraint = new VersionConstraint.parse('^0.0.1'); |
| OLD | NEW |