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

Unified Diff: runtime/lib/string_patch.dart

Issue 15339002: Reuse _isOneByteWhitespace in all the classes for implementing _isWhitespace. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | 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
===================================================================
--- runtime/lib/string_patch.dart (revision 22871)
+++ runtime/lib/string_patch.dart (working copy)
@@ -199,6 +199,15 @@
String _substringUncheckedNative(int startIndex, int endIndex)
native "StringBase_substringUnchecked";
+ // Checks for one-byte whitespaces only.
+ // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
+ // whitespaces for one byte strings.
+ static bool _isOneByteWhitespace(int codePoint) {
+ return
+ (codePoint == 32) || // Space.
+ ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc.
+ }
+
String trim() {
final int len = this.length;
int first = 0;
@@ -510,13 +519,8 @@
int get hashCode native "String_getHashCode";
- // Checks for one-byte whitespaces only.
- // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
- // whitespaces for one byte strings.
bool _isWhitespace(int codePoint) {
- return
- (codePoint == 32) || // Space.
- ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc.
+ return _StringBase._isOneByteWhitespace(codePoint);
}
String _substringUncheckedNative(int startIndex, int endIndex)
@@ -568,13 +572,9 @@
"_TwoByteString can only be allocated by the VM");
}
- // Checks for one-byte whitespaces only.
- // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
- // whitespaces. Add checking for multi-byte whitespace codepoints.
bool _isWhitespace(int codePoint) {
- return
- (codePoint == 32) || // Space.
- ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc.
+ // For now we only check for one byte white space characters.
+ return _StringBase._isOneByteWhitespace(codePoint);
}
}
@@ -585,13 +585,8 @@
"_ExternalOneByteString can only be allocated by the VM");
}
- // Checks for one-byte whitespaces only.
- // TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
- // whitespaces for one byte strings.
bool _isWhitespace(int codePoint) {
- return
- (codePoint == 32) || // Space.
- ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc.
+ return _StringBase._isOneByteWhitespace(codePoint);
}
}
@@ -606,9 +601,8 @@
// TODO(srdjan): Investigate if 0x85 (NEL) and 0xA0 (NBSP) are valid
// whitespaces. Add checking for multi-byte whitespace codepoints.
bool _isWhitespace(int codePoint) {
- return
- (codePoint == 32) || // Space.
- ((9 <= codePoint) && (codePoint <= 13)); // CR, LF, TAB, etc.
+ // For now we only check for one byte white space characters.
+ return _StringBase._isOneByteWhitespace(codePoint);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698