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

Unified Diff: runtime/lib/string.dart

Issue 8510066: Fix String.trim implementation (follow spec). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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: runtime/lib/string.dart
===================================================================
--- runtime/lib/string.dart (revision 1518)
+++ runtime/lib/string.dart (working copy)
@@ -160,7 +160,7 @@
}
String trim() {
- int len = this.length;
+ final int len = this.length;
int first = 0;
for (; first < len; first++) {
if (!_isWhitespace(this.charCodeAt(first))) {
@@ -177,7 +177,13 @@
break;
}
}
- return substringUnchecked_(first, last + 1);
+ if ((first == 0) && (last == len - 1)) {
siva 2011/11/14 21:26:17 (len - 1)
srdjan 2011/11/14 22:15:33 Done.
+ // Returns this string if it does not have leading or trailing
+ // whitespaces.
+ return this;
+ } else {
+ return substringUnchecked_(first, last + 1);
+ }
}
bool contains(Pattern other, [int startIndex = 0]) {

Powered by Google App Engine
This is Rietveld 408576698