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

Unified Diff: sdk/lib/core/string.dart

Issue 745573002: Create generic check methods for RangeError causing checks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix long line Created 6 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
« no previous file with comments | « sdk/lib/core/iterable.dart ('k') | sdk/lib/internal/iterable.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/string.dart
diff --git a/sdk/lib/core/string.dart b/sdk/lib/core/string.dart
index b95c6e146a6ed9fe0d44573804ec7d3b384facaa..e4a1c1d5c9712f50e45c9578eaa7e1e063ddb3d1 100644
--- a/sdk/lib/core/string.dart
+++ b/sdk/lib/core/string.dart
@@ -640,14 +640,11 @@ class RuneIterator implements BidirectionalIterator<int> {
* and a [movePrevious] will use the rune ending just before [index] as the
* the current value.
*
- * It is an error if the [index] position is in the middle of a surrogate
- * pair.
+ * The [index] position must not be in the middle of a surrogate pair.
*/
RuneIterator.at(String string, int index)
: string = string, _position = index, _nextPosition = index {
- if (index < 0 || index > string.length) {
- throw new RangeError.range(index, 0, string.length);
- }
+ RangeError.checkValueInInterval(index, 0, string.length);
_checkSplitSurrogate(index);
}
@@ -677,9 +674,7 @@ class RuneIterator implements BidirectionalIterator<int> {
* Setting the position to the end of then string will set [current] to null.
*/
void set rawIndex(int rawIndex) {
- if (rawIndex >= string.length) {
- throw new RangeError.index(rawIndex, string);
- }
+ RangeError.checkValidIndex(rawIndex, string, "rawIndex");
reset(rawIndex);
moveNext();
}
@@ -695,9 +690,7 @@ class RuneIterator implements BidirectionalIterator<int> {
* is an error. So is setting it in the middle of a surrogate pair.
*/
void reset([int rawIndex = 0]) {
- if (rawIndex < 0 || rawIndex > string.length) {
- throw new RangeError.range(rawIndex, 0, string.length);
- }
+ RangeError.checkValueInInterval(rawIndex, 0, string.length, "rawIndex");
_checkSplitSurrogate(rawIndex);
_position = _nextPosition = rawIndex;
_currentCodePoint = null;
« no previous file with comments | « sdk/lib/core/iterable.dart ('k') | sdk/lib/internal/iterable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698