| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 polymer_expressions.expression; | 5 library polymer_expressions.expression; |
| 6 | 6 |
| 7 import 'visitor.dart'; | 7 import 'visitor.dart'; |
| 8 | 8 |
| 9 // Helper functions for building expression trees programmatically | 9 // Helper functions for building expression trees programmatically |
| 10 | 10 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 if (a == null || b == null) return false; | 216 if (a == null || b == null) return false; |
| 217 if (a.length != b.length) return false; | 217 if (a.length != b.length) return false; |
| 218 for (int i = 0; i < a.length; i++) { | 218 for (int i = 0; i < a.length; i++) { |
| 219 if (a[i] != b[i]) return false; | 219 if (a[i] != b[i]) return false; |
| 220 } | 220 } |
| 221 return true; | 221 return true; |
| 222 } | 222 } |
| 223 | 223 |
| 224 int _hashList(List l) { | 224 int _hashList(List l) { |
| 225 var hash = l.fold(0, | 225 var hash = l.fold(0, |
| 226 (hash, item) => _JenkinsSmiHash.combine(hash, item.hashCode)); | 226 (h, item) => _JenkinsSmiHash.combine(h, item.hashCode)); |
| 227 return _JenkinsSmiHash.finish(hash); | 227 return _JenkinsSmiHash.finish(hash); |
| 228 } | 228 } |
| 229 | 229 |
| 230 class _JenkinsSmiHash { | 230 class _JenkinsSmiHash { |
| 231 // TODO: Bug 11617- This class should be optimized and standardized elsewhere. | 231 // TODO: Bug 11617- This class should be optimized and standardized elsewhere. |
| 232 | 232 |
| 233 static int combine(int hash, int value) { | 233 static int combine(int hash, int value) { |
| 234 hash = 0x1fffffff & (hash + value); | 234 hash = 0x1fffffff & (hash + value); |
| 235 hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); | 235 hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); |
| 236 return hash ^ (hash >> 6); | 236 return hash ^ (hash >> 6); |
| 237 } | 237 } |
| 238 | 238 |
| 239 static int finish(int hash) { | 239 static int finish(int hash) { |
| 240 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); | 240 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); |
| 241 hash = hash ^ (hash >> 11); | 241 hash = hash ^ (hash >> 11); |
| 242 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); | 242 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); |
| 243 } | 243 } |
| 244 | 244 |
| 245 static int hash2(a, b) => finish(combine(combine(0, a), b)); | 245 static int hash2(a, b) => finish(combine(combine(0, a), b)); |
| 246 | 246 |
| 247 static int hash3(a, b, c) => finish(combine(combine(combine(0, a), b), c)); | 247 static int hash3(a, b, c) => finish(combine(combine(combine(0, a), b), c)); |
| 248 | 248 |
| 249 static int hash4(a, b, c, d) => | 249 static int hash4(a, b, c, d) => |
| 250 finish(combine(combine(combine(combine(0, a), b), c), d)); | 250 finish(combine(combine(combine(combine(0, a), b), c), d)); |
| 251 } | 251 } |
| OLD | NEW |