Index: pkg/yaml/lib/src/deep_equals.dart |
diff --git a/pkg/yaml/lib/src/deep_equals.dart b/pkg/yaml/lib/src/deep_equals.dart |
index bce4aadf2e9c29b222c662d07d653c2674fa7c0e..1e1f7ed76c5a949a33de3587d78981244b3780b2 100644 |
--- a/pkg/yaml/lib/src/deep_equals.dart |
+++ b/pkg/yaml/lib/src/deep_equals.dart |
@@ -4,8 +4,10 @@ |
library deep_equals; |
-/// Returns whether two objects are structurally equivalent. This considers NaN |
-/// values to be equivalent. It also handles self-referential structures. |
+/// Returns whether two objects are structurally equivalent. |
+/// |
+/// This considers `NaN` values to be equivalent. It also handles |
+/// self-referential structures. |
bool deepEquals(obj1, obj2, [List parents1, List parents2]) { |
if (identical(obj1, obj2)) return true; |
if (parents1 == null) { |
@@ -30,8 +32,8 @@ bool deepEquals(obj1, obj2, [List parents1, List parents2]) { |
return _listEquals(obj1, obj2, parents1, parents2); |
} else if (obj1 is Map && obj2 is Map) { |
return _mapEquals(obj1, obj2, parents1, parents2); |
- } else if (obj1 is double && obj2 is double) { |
- return _doubleEquals(obj1, obj2); |
+ } else if (obj1 is num && obj2 is num) { |
+ return _numEquals(obj1, obj2); |
} else { |
return obj1 == obj2; |
} |
@@ -64,9 +66,11 @@ bool _mapEquals(Map map1, Map map2, List parents1, List parents2) { |
return true; |
} |
-/// Returns whether two doubles are equivalent. This differs from `d1 == d2` in |
-/// that it considers NaN to be equal to itself. |
-bool _doubleEquals(double d1, double d2) { |
- if (d1.isNaN && d2.isNaN) return true; |
- return d1 == d2; |
+/// Returns whether two numbers are equivalent. |
+/// |
+/// This differs from `n1 == n2` in that it considers `NaN` to be equal to |
+/// itself. |
+bool _numEquals(num n1, num n2) { |
+ if (n1.isNaN && n2.isNaN) return true; |
+ return n1 == n2; |
} |