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

Unified Diff: runtime/lib/string_patch.dart

Issue 596763002: Optimize int.parse with a radix. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head. Created 6 years, 3 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
« runtime/lib/integers_patch.dart ('K') | « runtime/lib/integers_patch.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+ return (codeUnit == 0x85) || (codeUnit == 0xA0);
Lasse Reichstein Nielsen 2014/09/23 11:34:45 Restructured to return false quickly on most ASCII
}
// 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) ||
« runtime/lib/integers_patch.dart ('K') | « runtime/lib/integers_patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698