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

Unified Diff: pkg/yaml/lib/src/utils.dart

Issue 302313007: Attach source range information to parsed YAML nodes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix tests Created 6 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 | « pkg/yaml/lib/src/parser.dart ('k') | pkg/yaml/lib/src/visitor.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/yaml/lib/src/utils.dart
diff --git a/pkg/yaml/lib/src/utils.dart b/pkg/yaml/lib/src/utils.dart
index 463af70133f992c7839a9ddfac29675ac25ba37b..84c1113a0b5a830e9d05426a5c581c10dbae9e1c 100644
--- a/pkg/yaml/lib/src/utils.dart
+++ b/pkg/yaml/lib/src/utils.dart
@@ -4,33 +4,12 @@
library yaml.utils;
-import 'package:collection/collection.dart';
+/// A pair of values.
+class Pair<E, F> {
+ final E first;
+ final F last;
-/// Returns a hash code for [obj] such that structurally equivalent objects
-/// will have the same hash code.
-///
-/// This supports deep equality for maps and lists, including those with
-/// self-referential structures.
-int hashCodeFor(obj) {
- var parents = [];
+ Pair(this.first, this.last);
- _hashCodeFor(value) {
- if (parents.any((parent) => identical(parent, value))) return -1;
-
- parents.add(value);
- try {
- if (value is Map) {
- var equality = const UnorderedIterableEquality();
- return equality.hash(value.keys.map(_hashCodeFor)) ^
- equality.hash(value.values.map(_hashCodeFor));
- } else if (value is Iterable) {
- return const IterableEquality().hash(value.map(hashCodeFor));
- }
- return value.hashCode;
- } finally {
- parents.removeLast();
- }
- }
-
- return _hashCodeFor(obj);
+ String toString() => '($first, $last)';
}
« no previous file with comments | « pkg/yaml/lib/src/parser.dart ('k') | pkg/yaml/lib/src/visitor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698