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

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

Issue 442693002: Special case substring(0, length) to return itself. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adding parentheses. Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 patch class String { 5 patch class String {
6 /* patch */ factory String.fromCharCodes(Iterable<int> charCodes) { 6 /* patch */ factory String.fromCharCodes(Iterable<int> charCodes) {
7 return _StringBase.createFromCharCodes(charCodes); 7 return _StringBase.createFromCharCodes(charCodes);
8 } 8 }
9 9
10 /* patch */ factory String.fromCharCode(int charCode) { 10 /* patch */ factory String.fromCharCode(int charCode) {
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 240
241 String _substringUnchecked(int startIndex, int endIndex) { 241 String _substringUnchecked(int startIndex, int endIndex) {
242 assert(endIndex != null); 242 assert(endIndex != null);
243 assert((startIndex >= 0) && (startIndex <= this.length)); 243 assert((startIndex >= 0) && (startIndex <= this.length));
244 assert((endIndex >= 0) && (endIndex <= this.length)); 244 assert((endIndex >= 0) && (endIndex <= this.length));
245 assert(startIndex <= endIndex); 245 assert(startIndex <= endIndex);
246 246
247 if (startIndex == endIndex) { 247 if (startIndex == endIndex) {
248 return ""; 248 return "";
249 } 249 }
250 if ((startIndex == 0) && (endIndex == this.length)) {
251 return this;
252 }
250 if ((startIndex + 1) == endIndex) { 253 if ((startIndex + 1) == endIndex) {
251 return this[startIndex]; 254 return this[startIndex];
252 } 255 }
253 return _substringUncheckedNative(startIndex, endIndex); 256 return _substringUncheckedNative(startIndex, endIndex);
254 } 257 }
255 258
256 String _substringUncheckedNative(int startIndex, int endIndex) 259 String _substringUncheckedNative(int startIndex, int endIndex)
257 native "StringBase_substringUnchecked"; 260 native "StringBase_substringUnchecked";
258 261
259 // Checks for one-byte whitespaces only. 262 // Checks for one-byte whitespaces only.
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 class _CodeUnits extends Object with ListMixin<int>, 1004 class _CodeUnits extends Object with ListMixin<int>,
1002 UnmodifiableListMixin<int> { 1005 UnmodifiableListMixin<int> {
1003 /** The string that this is the code units of. */ 1006 /** The string that this is the code units of. */
1004 String _string; 1007 String _string;
1005 1008
1006 _CodeUnits(this._string); 1009 _CodeUnits(this._string);
1007 1010
1008 int get length => _string.length; 1011 int get length => _string.length;
1009 int operator[](int i) => _string.codeUnitAt(i); 1012 int operator[](int i) => _string.codeUnitAt(i);
1010 } 1013 }
OLDNEW
« 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