| OLD | NEW |
| 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 'characters.dart'; | 7 import 'characters.dart'; |
| 8 import 'util_implementation.dart'; | 8 import 'util_implementation.dart'; |
| 9 | 9 |
| 10 export 'emptyset.dart'; | 10 export 'emptyset.dart'; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 int high = existing >> 15; | 35 int high = existing >> 15; |
| 36 int low = existing & 0x7fff; | 36 int low = existing & 0x7fff; |
| 37 return ((high * 13) ^ (low * 997) ^ h) & SMI_MASK; | 37 return ((high * 13) ^ (low * 997) ^ h) & SMI_MASK; |
| 38 } | 38 } |
| 39 | 39 |
| 40 /// Mix the bits of `object.hashCode` with [existing]. | 40 /// Mix the bits of `object.hashCode` with [existing]. |
| 41 static int objectHash(Object object, [int existing = 0]) { | 41 static int objectHash(Object object, [int existing = 0]) { |
| 42 return mixHashCodeBits(existing, object.hashCode); | 42 return mixHashCodeBits(existing, object.hashCode); |
| 43 } | 43 } |
| 44 | 44 |
| 45 /// Mix the bits of `.hashCode` all non-null objects. |
| 46 static int objectsHash(Object obj1, [Object obj2, Object obj3]) { |
| 47 int hash = 0; |
| 48 if (obj3 != null) hash = objectHash(obj3, hash); |
| 49 if (obj2 != null) hash = objectHash(obj2, hash); |
| 50 return objectHash(obj1, hash); |
| 51 } |
| 52 |
| 45 /// Mix the bits of the element hash codes of [list] with [existing]. | 53 /// Mix the bits of the element hash codes of [list] with [existing]. |
| 46 static int listHash(List list, [int existing = 0]) { | 54 static int listHash(List list, [int existing = 0]) { |
| 47 int h = existing; | 55 int h = existing; |
| 48 int length = list.length; | 56 int length = list.length; |
| 49 for (int i = 0; i < length; i++) { | 57 for (int i = 0; i < length; i++) { |
| 50 h = mixHashCodeBits(h, list[i].hashCode); | 58 h = mixHashCodeBits(h, list[i].hashCode); |
| 51 } | 59 } |
| 52 return h; | 60 return h; |
| 53 } | 61 } |
| 54 | 62 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 if (usedNames.contains(suggestedName)) { | 241 if (usedNames.contains(suggestedName)) { |
| 234 int counter = 0; | 242 int counter = 0; |
| 235 while (usedNames.contains(result)) { | 243 while (usedNames.contains(result)) { |
| 236 counter++; | 244 counter++; |
| 237 result = "$suggestedName$counter"; | 245 result = "$suggestedName$counter"; |
| 238 } | 246 } |
| 239 } | 247 } |
| 240 usedNames.add(result); | 248 usedNames.add(result); |
| 241 return result; | 249 return result; |
| 242 } | 250 } |
| OLD | NEW |