| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // Character constants. | 5 // Character constants. |
| 6 const int _zero = 0x30; | 6 const int _zero = 0x30; |
| 7 const int _upperCaseA = 0x41; | 7 const int _upperCaseA = 0x41; |
| 8 const int _upperCaseZ = 0x5a; | 8 const int _upperCaseZ = 0x5a; |
| 9 const int _lowerCaseA = 0x61; | 9 const int _lowerCaseA = 0x61; |
| 10 const int _lowerCaseZ = 0x7a; | 10 const int _lowerCaseZ = 0x7a; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 bool equalsIgnoreAsciiCase(String a, String b) { | 27 bool equalsIgnoreAsciiCase(String a, String b) { |
| 28 if (a.length != b.length) return false; | 28 if (a.length != b.length) return false; |
| 29 for (int i = 0; i < a.length; i++) { | 29 for (int i = 0; i < a.length; i++) { |
| 30 var aChar = a.codeUnitAt(i); | 30 var aChar = a.codeUnitAt(i); |
| 31 var bChar = b.codeUnitAt(i); | 31 var bChar = b.codeUnitAt(i); |
| 32 if (aChar == bChar) continue; | 32 if (aChar == bChar) continue; |
| 33 // Quick-check for whether this may be different cases of the same letter. | 33 // Quick-check for whether this may be different cases of the same letter. |
| 34 if (aChar ^ bChar != _asciiCaseBit) return false; | 34 if (aChar ^ bChar != _asciiCaseBit) return false; |
| 35 // If it's possible, then check if either character is actually an ASCII | 35 // If it's possible, then check if either character is actually an ASCII |
| 36 // letter. | 36 // letter. |
| 37 int aCharUpperCase = aChar | _asciiCaseBit; | 37 int aCharLowerCase = aChar | _asciiCaseBit; |
| 38 if (_upperCaseA <= aCharUpperCase && aCharUpperCase <= _upperCaseZ) { | 38 if (_lowerCaseA <= aCharLowerCase && aCharLowerCase <= _lowerCaseZ) { |
| 39 continue; | 39 continue; |
| 40 } | 40 } |
| 41 return false; | 41 return false; |
| 42 } | 42 } |
| 43 return true; | 43 return true; |
| 44 } | 44 } |
| 45 | 45 |
| 46 | 46 |
| 47 /// Hash code for a string which is compatible with [equalsIgnoreAsciiCase]. | 47 /// Hash code for a string which is compatible with [equalsIgnoreAsciiCase]. |
| 48 /// | 48 /// |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 /// If there is no non-zero digits before, then leading zeros at [index] | 388 /// If there is no non-zero digits before, then leading zeros at [index] |
| 389 /// are also ignored when comparing numerically. If there is a non-zero digit | 389 /// are also ignored when comparing numerically. If there is a non-zero digit |
| 390 /// before, then zeros at [index] are significant. | 390 /// before, then zeros at [index] are significant. |
| 391 bool _isNonZeroNumberSuffix(String string, int index) { | 391 bool _isNonZeroNumberSuffix(String string, int index) { |
| 392 while (--index >= 0) { | 392 while (--index >= 0) { |
| 393 int char = string.codeUnitAt(index); | 393 int char = string.codeUnitAt(index); |
| 394 if (char != _zero) return _isDigit(char); | 394 if (char != _zero) return _isDigit(char); |
| 395 } | 395 } |
| 396 return false; | 396 return false; |
| 397 } | 397 } |
| OLD | NEW |