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

Side by Side Diff: runtime/lib/string_base.dart

Issue 11419194: Improve performance of String.split for 1 and 0 character results. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/lib/math_patch.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /** 5 /**
6 * [_StringBase] contains common methods used by concrete String 6 * [_StringBase] contains common methods used by concrete String
7 * implementations, e.g., _OneByteString. 7 * implementations, e.g., _OneByteString.
8 */ 8 */
9 class _StringBase { 9 class _StringBase {
10 10
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 if ((startIndex < 0) || (startIndex > this.length)) { 146 if ((startIndex < 0) || (startIndex > this.length)) {
147 throw new RangeError.value(startIndex); 147 throw new RangeError.value(startIndex);
148 } 148 }
149 if ((endIndex < 0) || (endIndex > this.length)) { 149 if ((endIndex < 0) || (endIndex > this.length)) {
150 throw new RangeError.value(endIndex); 150 throw new RangeError.value(endIndex);
151 } 151 }
152 if (startIndex > endIndex) { 152 if (startIndex > endIndex) {
153 throw new RangeError.value(startIndex); 153 throw new RangeError.value(startIndex);
154 } 154 }
155 if (startIndex == endIndex) {
156 return "";
157 }
158 if ((startIndex + 1) == endIndex) {
159 return this[startIndex];
160 }
155 return _substringUnchecked(startIndex, endIndex); 161 return _substringUnchecked(startIndex, endIndex);
156 } 162 }
157 163
158 String _substringUnchecked(int startIndex, int endIndex) 164 String _substringUnchecked(int startIndex, int endIndex)
159 native "StringBase_substringUnchecked"; 165 native "StringBase_substringUnchecked";
160 166
161 String trim() { 167 String trim() {
162 final int len = this.length; 168 final int len = this.length;
163 int first = 0; 169 int first = 0;
164 for (; first < len; first++) { 170 for (; first < len; first++) {
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 for (int g in groups) { 484 for (int g in groups) {
479 result.add(group(g)); 485 result.add(group(g));
480 } 486 }
481 return result; 487 return result;
482 } 488 }
483 489
484 final int start; 490 final int start;
485 final String str; 491 final String str;
486 final String pattern; 492 final String pattern;
487 } 493 }
OLDNEW
« no previous file with comments | « runtime/lib/math_patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698