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

Unified Diff: packages/collection/lib/src/comparators.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 5 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
Index: packages/collection/lib/src/comparators.dart
diff --git a/packages/collection/lib/src/comparators.dart b/packages/collection/lib/src/comparators.dart
index 05615ba1b9f5f48453533e35cf09d8fcd9d5f78e..5fc55b2e268eecf13215d2d2bac7eb5f326d3498 100644
--- a/packages/collection/lib/src/comparators.dart
+++ b/packages/collection/lib/src/comparators.dart
@@ -2,14 +2,12 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library dart.pkg.collection.comparators;
-
// Character constants.
-const int _zero = 0x30;
-const int _upperCaseA = 0x41;
-const int _upperCaseZ = 0x5a;
-const int _lowerCaseA = 0x61;
-const int _lowerCaseZ = 0x7a;
+const int _zero = 0x30;
+const int _upperCaseA = 0x41;
+const int _upperCaseZ = 0x5a;
+const int _lowerCaseA = 0x61;
+const int _lowerCaseZ = 0x7a;
const int _asciiCaseBit = 0x20;
/// Checks if strings [a] and [b] differ only on the case of ASCII letters.
@@ -36,8 +34,8 @@ bool equalsIgnoreAsciiCase(String a, String b) {
if (aChar ^ bChar != _asciiCaseBit) return false;
// If it's possible, then check if either character is actually an ASCII
// letter.
- int aCharUpperCase = aChar | _asciiCaseBit;
- if (_upperCaseA <= aCharUpperCase && aCharUpperCase <= _upperCaseZ) {
+ int aCharLowerCase = aChar | _asciiCaseBit;
+ if (_lowerCaseA <= aCharLowerCase && aCharLowerCase <= _lowerCaseZ) {
continue;
}
return false;
@@ -45,7 +43,6 @@ bool equalsIgnoreAsciiCase(String a, String b) {
return true;
}
-
/// Hash code for a string which is compatible with [equalsIgnoreAsciiCase].
///
/// The hash code is unaffected by changing the case of ASCII letters, but
@@ -71,7 +68,6 @@ int hashIgnoreAsciiCase(String string) {
return 0x1fffffff & (hash + ((0x00003fff & hash) << 15));
}
-
/// Compares [a] and [b] lexically, converting ASCII letters to upper case.
///
/// Comparison treats all lower-case ASCII letters as upper-case letters,
@@ -109,7 +105,6 @@ int compareAsciiUpperCase(String a, String b) {
return defaultResult.sign;
}
-
/// Compares [a] and [b] lexically, converting ASCII letters to lower case.
///
/// Comparison treats all upper-case ASCII letters as lower-case letters,
@@ -147,7 +142,7 @@ int compareAsciiLowerCase(String a, String b) {
return defaultResult.sign;
}
-/// Compares strings [a] and [b] according to [natural sort ordering].
+/// Compares strings [a] and [b] according to [natural sort ordering][].
///
/// A natural sort ordering is a lexical ordering where embedded
/// numerals (digit sequences) are treated as a single unit and ordered by
@@ -177,7 +172,7 @@ int compareNatural(String a, String b) {
}
/// Compares strings [a] and [b] according to lower-case
-/// [natural sort ordering].
+/// [natural sort ordering][].
///
/// ASCII letters are converted to lower case before being compared, like
/// for [compareAsciiLowerCase], then the result is compared like for
@@ -214,7 +209,7 @@ int compareAsciiLowerCaseNatural(String a, String b) {
}
/// Compares strings [a] and [b] according to upper-case
-/// [natural sort ordering].
+/// [natural sort ordering][].
///
/// ASCII letters are converted to upper case before being compared, like
/// for [compareAsciiUpperCase], then the result is compared like for
@@ -260,8 +255,7 @@ int compareAsciiUpperCaseNatural(String a, String b) {
/// is a digit, and if so, the the one with the digit is the greater number.
///
/// Otherwise just returns the difference between [aChar] and [bChar].
-int _compareNaturally(
- String a, String b, int index, int aChar, int bChar) {
+int _compareNaturally(String a, String b, int index, int aChar, int bChar) {
assert(aChar != bChar);
var aIsDigit = _isDigit(aChar);
var bIsDigit = _isDigit(bChar);
@@ -304,14 +298,14 @@ int _compareNumerically(String a, String b, int aChar, int bChar, int index) {
if (aChar == _zero) {
do {
aIndex++;
- if (aIndex == a.length) return -1; // number in a is zero, b is not.
+ if (aIndex == a.length) return -1; // number in a is zero, b is not.
aChar = a.codeUnitAt(aIndex);
} while (aChar == _zero);
if (!_isDigit(aChar)) return -1;
} else if (bChar == _zero) {
do {
bIndex++;
- if (bIndex == b.length) return 1; // number in b is zero, a is not.
+ if (bIndex == b.length) return 1; // number in b is zero, a is not.
bChar = b.codeUnitAt(bIndex);
} while (bChar == _zero);
if (!_isDigit(bChar)) return 1;
@@ -345,7 +339,7 @@ int _compareNumerically(String a, String b, int aChar, int bChar, int index) {
// bChar is non-digit, so a has longer number.
return 1;
} else if (bIsDigit) {
- return -1; // b has longer number.
+ return -1; // b has longer number.
} else {
// Neither is digit, so numbers had same numerical value.
// Fall back on number of leading zeros

Powered by Google App Engine
This is Rietveld 408576698