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

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

Issue 499073003: Use Uint8List for byte lists in dart:convert. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 | « sdk/lib/_internal/lib/convert_patch.dart ('k') | sdk/lib/convert/byte_conversion.dart » ('j') | 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) 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 69
70 // Superclass for [AsciiEncoder] and [Latin1Encoder]. 70 // Superclass for [AsciiEncoder] and [Latin1Encoder].
71 // Generalizes common operations that only differ by a mask; 71 // Generalizes common operations that only differ by a mask;
72 class _UnicodeSubsetEncoder extends Converter<String, List<int>> { 72 class _UnicodeSubsetEncoder extends Converter<String, List<int>> {
73 final int _subsetMask; 73 final int _subsetMask;
74 74
75 const _UnicodeSubsetEncoder(this._subsetMask); 75 const _UnicodeSubsetEncoder(this._subsetMask);
76 76
77 List<int> convert(String string) { 77 List<int> convert(String string) {
78 // TODO(11971): Use Uint8List when possible. 78 List result = new Uint8List(string.length);
79 List result = new List<int>(string.length);
80 for (int i = 0; i < string.length; i++) { 79 for (int i = 0; i < string.length; i++) {
81 var codeUnit = string.codeUnitAt(i); 80 var codeUnit = string.codeUnitAt(i);
82 if ((codeUnit & ~_subsetMask) != 0) { 81 if ((codeUnit & ~_subsetMask) != 0) {
83 throw new ArgumentError("String contains invalid characters."); 82 throw new ArgumentError("String contains invalid characters.");
84 } 83 }
85 result[i] = codeUnit; 84 result[i] = codeUnit;
86 } 85 }
87 return result; 86 return result;
88 } 87 }
89 88
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } 299 }
301 if (start < end) { 300 if (start < end) {
302 if (start != 0 || end != length) { 301 if (start != 0 || end != length) {
303 source = source.sublist(start, end); 302 source = source.sublist(start, end);
304 } 303 }
305 add(source); 304 add(source);
306 } 305 }
307 if (isLast) close(); 306 if (isLast) close();
308 } 307 }
309 } 308 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/lib/convert_patch.dart ('k') | sdk/lib/convert/byte_conversion.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698