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

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

Issue 277593005: Fix analyzer warnings in the YAML package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 | « no previous file | pkg/yaml/lib/src/parser.dart » ('j') | pkg/yaml/lib/src/parser.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | pkg/yaml/lib/src/parser.dart » ('j') | pkg/yaml/lib/src/parser.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698