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

Unified Diff: lib/src/compiler/type_utilities.dart

Issue 2002153006: More consistent order of type caches (Closed) Base URL: https://github.com/dart-lang/dev_compiler@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/runtime/dart_sdk.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/compiler/type_utilities.dart
diff --git a/lib/src/compiler/type_utilities.dart b/lib/src/compiler/type_utilities.dart
index 0614029713dd2091e1e045730f5d863a64630c12..2d1393650047cbcb03a3b150da395cac600e02f5 100644
--- a/lib/src/compiler/type_utilities.dart
+++ b/lib/src/compiler/type_utilities.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'dart:collection' show HashMap, HashSet;
+import 'dart:collection' show HashMap, HashSet, LinkedHashMap;
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
@@ -33,7 +33,10 @@ Set<TypeParameterElement> freeTypeParameters(DartType t) {
/// are emitted in place with a hoisted variable for a cache.
class _CacheTable {
/// Mapping from types to their canonical names.
- final _names = new HashMap<DartType, JS.TemporaryId>();
+ // Use a LinkedHashMap to maintain key insertion order so the generated code
+ // is stable under slight perturbation. (If this is not good enough we could
+ // sort by name to canonicalize order.)
+ final _names = new LinkedHashMap<DartType, JS.TemporaryId>();
Iterable<DartType> get keys => _names.keys.toList();
JS.Statement _dischargeType(DartType type) {
« no previous file with comments | « lib/runtime/dart_sdk.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698