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

Side by Side Diff: pkg/compiler/lib/src/util/util.dart

Issue 2112893002: Use unordered map hash on ConstructedConstantValue. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 dart2js.util; 5 library dart2js.util;
6 6
7 import 'util_implementation.dart'; 7 import 'util_implementation.dart';
8 import 'characters.dart'; 8 import 'characters.dart';
9 9
10 export 'setlet.dart'; 10 export 'setlet.dart';
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 /// Mix the bits of the element hash codes of [list] with [existing]. 45 /// Mix the bits of the element hash codes of [list] with [existing].
46 static int listHash(List list, [int existing = 0]) { 46 static int listHash(List list, [int existing = 0]) {
47 int h = existing; 47 int h = existing;
48 int length = list.length; 48 int length = list.length;
49 for (int i = 0; i < length; i++) { 49 for (int i = 0; i < length; i++) {
50 h = mixHashCodeBits(h, list[i].hashCode); 50 h = mixHashCodeBits(h, list[i].hashCode);
51 } 51 }
52 return h; 52 return h;
53 } 53 }
54 54
55 /// Mix the bits of the hash codes of the unordered key/value from [map] with
56 /// [existing].
57 static int unorderedMapHash(Map map, [int existing = 0]) {
58 int h = 0;
59 for (var key in map.keys) {
60 h ^= objectHash(key, objectHash(map[key]));
61 }
62 return mixHashCodeBits(h, existing);
63 }
64
55 /// Mix the bits of the key/value hash codes from [map] with [existing]. 65 /// Mix the bits of the key/value hash codes from [map] with [existing].
56 static int mapHash(Map map, [int existing = 0]) { 66 static int mapHash(Map map, [int existing = 0]) {
57 int h = existing; 67 int h = existing;
58 for (var key in map.keys) { 68 for (var key in map.keys) {
59 h = mixHashCodeBits(h, key.hashCode); 69 h = mixHashCodeBits(h, key.hashCode);
60 h = mixHashCodeBits(h, map[key].hashCode); 70 h = mixHashCodeBits(h, map[key].hashCode);
61 } 71 }
62 return h; 72 return h;
63 } 73 }
64 } 74 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 if (usedNames.contains(suggestedName)) { 233 if (usedNames.contains(suggestedName)) {
224 int counter = 0; 234 int counter = 0;
225 while (usedNames.contains(result)) { 235 while (usedNames.contains(result)) {
226 counter++; 236 counter++;
227 result = "$suggestedName$counter"; 237 result = "$suggestedName$counter";
228 } 238 }
229 } 239 }
230 usedNames.add(result); 240 usedNames.add(result);
231 return result; 241 return result;
232 } 242 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/constants/values.dart ('k') | tests/compiler/dart2js/constant_value_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698