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

Side by Side Diff: sdk/lib/convert/ascii.dart

Issue 1409053007: More optimization of _uriEncode. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Call directly to specialized UTF-8 version. Created 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | sdk/lib/core/core.dart » ('j') | sdk/lib/core/uri.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart.convert; 5 part of dart.convert;
6 6
7 /** 7 /**
8 * An instance of the default implementation of the [AsciiCodec]. 8 * An instance of the default implementation of the [AsciiCodec].
9 * 9 *
10 * This instance provides a convenient access to the most common ASCII 10 * This instance provides a convenient access to the most common ASCII
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 Sink _sink; 283 Sink _sink;
284 _SimpleAsciiDecoderSink(this._sink); 284 _SimpleAsciiDecoderSink(this._sink);
285 285
286 void close() { 286 void close() {
287 _sink.close(); 287 _sink.close();
288 } 288 }
289 289
290 void add(List<int> source) { 290 void add(List<int> source) {
291 for (int i = 0; i < source.length; i++) { 291 for (int i = 0; i < source.length; i++) {
292 if ((source[i] & ~_ASCII_MASK) != 0) { 292 if ((source[i] & ~_ASCII_MASK) != 0) {
293 throw new FormatException("Source contains non-ASCII bytes."); 293 throw new FormatException("Source contains non-ASCII bytes.",
294 source, i);
294 } 295 }
295 } 296 }
296 _sink.add(new String.fromCharCodes(source)); 297 _sink.add(new String.fromCharCodes(source));
297 } 298 }
298 299
299 void addSlice(List<int> source, int start, int end, bool isLast) { 300 void addSlice(List<int> source, int start, int end, bool isLast) {
300 final int length = source.length; 301 final int length = source.length;
301 RangeError.checkValidRange(start, end, length); 302 RangeError.checkValidRange(start, end, length);
302 if (start < end) { 303 if (start < end) {
303 if (start != 0 || end != length) { 304 if (start != 0 || end != length) {
304 source = source.sublist(start, end); 305 source = source.sublist(start, end);
305 } 306 }
306 add(source); 307 add(source);
307 } 308 }
308 if (isLast) close(); 309 if (isLast) close();
309 } 310 }
310 } 311 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/core/core.dart » ('j') | sdk/lib/core/uri.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698