| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |