Chromium Code Reviews| 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 utils; | 5 library utils; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 import 'path.dart'; | 10 import 'path.dart'; |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 } else { | 263 } else { |
| 264 throw new Exception("Can't build hashcode for non json-like object " | 264 throw new Exception("Can't build hashcode for non json-like object " |
| 265 "(${object.runtimeType})"); | 265 "(${object.runtimeType})"); |
| 266 } | 266 } |
| 267 } | 267 } |
| 268 | 268 |
| 269 int get value => _value; | 269 int get value => _value; |
| 270 } | 270 } |
| 271 | 271 |
| 272 bool deepJsonCompare(Object a, Object b) { | 272 bool deepJsonCompare(Object a, Object b) { |
| 273 if (a == null || a is num || a is String) { | 273 if (a == null || a is num || a is String || a is Uri) { |
|
Bill Hesse
2015/02/26 09:31:11
Please add bool as well, like in the hash builder
| |
| 274 return a == b; | 274 return a == b; |
| 275 } else if (a is List) { | 275 } else if (a is List) { |
| 276 if (b is List) { | 276 if (b is List) { |
| 277 if (a.length != b.length) return false; | 277 if (a.length != b.length) return false; |
| 278 | 278 |
| 279 for (int i = 0; i < a.length; i++) { | 279 for (int i = 0; i < a.length; i++) { |
| 280 if (!deepJsonCompare(a[i], b[i])) return false; | 280 if (!deepJsonCompare(a[i], b[i])) return false; |
| 281 } | 281 } |
| 282 return true; | 282 return true; |
| 283 } | 283 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 301 | 301 |
| 302 class UniqueObject { | 302 class UniqueObject { |
| 303 static int _nextId = 1; | 303 static int _nextId = 1; |
| 304 final int _hashCode; | 304 final int _hashCode; |
| 305 | 305 |
| 306 int get hashCode => _hashCode; | 306 int get hashCode => _hashCode; |
| 307 operator==(other) => other is UniqueObject && _hashCode == other._hashCode; | 307 operator==(other) => other is UniqueObject && _hashCode == other._hashCode; |
| 308 | 308 |
| 309 UniqueObject() : _hashCode = ++_nextId; | 309 UniqueObject() : _hashCode = ++_nextId; |
| 310 } | 310 } |
| OLD | NEW |