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

Unified Diff: sdk/lib/convert/latin1.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/convert/ascii.dart ('k') | sdk/lib/convert/utf.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/convert/latin1.dart
diff --git a/sdk/lib/convert/latin1.dart b/sdk/lib/convert/latin1.dart
index dd9c65f0e3859734fb06783112078322339c7f83..7f7fef883ca18a23d209a27193fdfea92e7ff277 100644
--- a/sdk/lib/convert/latin1.dart
+++ b/sdk/lib/convert/latin1.dart
@@ -132,12 +132,7 @@ class _Latin1DecoderSink extends ByteConversionSinkBase {
}
void addSlice(List<int> source, int start, int end, bool isLast) {
- if (start < 0 || start > source.length) {
- throw new RangeError.range(start, 0, source.length);
- }
- if (end < start || end > source.length) {
- throw new RangeError.range(end, start, source.length);
- }
+ RangeError.checkValidRange(start, end, source.length);
for (int i = start; i < end; i++) {
int char = source[i];
if (char > _LATIN1_MASK || char < 0) {
@@ -157,12 +152,7 @@ class _Latin1AllowInvalidDecoderSink extends _Latin1DecoderSink {
_Latin1AllowInvalidDecoderSink(StringConversionSink sink): super(sink);
void addSlice(List<int> source, int start, int end, bool isLast) {
- if (start < 0 || start > source.length) {
- throw new RangeError.range(start, 0, source.length);
- }
- if (end < start || end > source.length) {
- throw new RangeError.range(end, start, source.length);
- }
+ RangeError.checkValidRange(start, end, source.length);
for (int i = start; i < end; i++) {
int char = source[i];
if (char > _LATIN1_MASK || char < 0) {
« no previous file with comments | « sdk/lib/convert/ascii.dart ('k') | sdk/lib/convert/utf.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698