Chromium Code Reviews| Index: runtime/lib/string_patch.dart |
| diff --git a/runtime/lib/string_patch.dart b/runtime/lib/string_patch.dart |
| index 9a454b114da22988e9e3ccbb692b605011f8ea72..deb5fcf161410224d29ca5ef2cfc6d68399fc668 100644 |
| --- a/runtime/lib/string_patch.dart |
| +++ b/runtime/lib/string_patch.dart |
| @@ -260,12 +260,13 @@ class _StringBase { |
| native "StringBase_substringUnchecked"; |
| // Checks for one-byte whitespaces only. |
| - static bool _isOneByteWhitespace(int codePoint) { |
| - return |
| - (codePoint == 32) || // Space. |
| - ((codePoint <= 13) ? (9 <= codePoint) // CR, LF, TAB, etc. |
| - : ((codePoint == 0x85) || // NEL |
| - (codePoint == 0xA0))); // NBSP |
| + static bool _isOneByteWhitespace(int codeUnit) { |
| + if (codeUnit <= 32) { |
| + return ((codeUnit == 32) || // Space. |
| + ((codeUnit <= 13) && (codeUnit >= 9))); // CR, LF, TAB, etc. |
| + } |
| + if (codeUnit < 0x85) return false; |
|
srdjan
2014/09/24 20:05:35
Is that check worth it? With two below you have th
Lasse Reichstein Nielsen
2014/09/24 20:26:30
Ack, probably not for the one-byte case. I copied
Lasse Reichstein Nielsen
2014/09/25 14:37:16
Fixed.
Any chance of optimizing so that (codeunit
|
| + return (codeUnit == 0x85) || (codeUnit == 0xA0); |
| } |
| // Characters with Whitespace property (Unicode 6.2). |
| @@ -284,7 +285,12 @@ class _StringBase { |
| // |
| // BOM: 0xFEFF |
| static bool _isTwoByteWhitespace(int codeUnit) { |
| - if (codeUnit <= 0xA0) return _isOneByteWhitespace(codeUnit); |
| + if (codeUnit <= 32) { |
| + return (codeUnit == 32) || |
| + ((codeUnit <= 13) && (codeUnit >= 9)); |
| + } |
| + if (codeUnit < 0x85) return false; |
| + if ((codeUnit == 0x85) || (codeUnit == 0xA0)) return true; |
| return (codeUnit <= 0x200A) |
| ? ((codeUnit == 0x1680) || |
| (codeUnit == 0x180E) || |