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

Side by Side Diff: sdk/lib/io/string_transformer.dart

Issue 12328104: Change new List(n) to return fixed length list. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head. Created 7 years, 9 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
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.io; 5 part of dart.io;
6 6
7 /** 7 /**
8 * String encodings. 8 * String encodings.
9 */ 9 */
10 class Encoding { 10 class Encoding {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } 213 }
214 214
215 215
216 abstract class _SingleByteDecoder 216 abstract class _SingleByteDecoder
217 extends StreamEventTransformer<List<int>, String> { 217 extends StreamEventTransformer<List<int>, String> {
218 final int _replacementChar; 218 final int _replacementChar;
219 219
220 _SingleByteDecoder(this._replacementChar); 220 _SingleByteDecoder(this._replacementChar);
221 221
222 void handleData(List<int> data, StreamSink<String> sink) { 222 void handleData(List<int> data, StreamSink<String> sink) {
223 var buffer = new List<int>.fixedLength(data.length); 223 var buffer = new List<int>(data.length);
224 for (int i = 0; i < data.length; i++) { 224 for (int i = 0; i < data.length; i++) {
225 int char = _decodeByte(data[i]); 225 int char = _decodeByte(data[i]);
226 if (char < 0) char = _replacementChar; 226 if (char < 0) char = _replacementChar;
227 buffer[i] = char; 227 buffer[i] = char;
228 } 228 }
229 sink.add(new String.fromCharCodes(buffer)); 229 sink.add(new String.fromCharCodes(buffer));
230 } 230 }
231 231
232 int _decodeByte(int byte); 232 int _decodeByte(int byte);
233 } 233 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 306
307 // Utility class for decoding Windows current code page data delivered 307 // Utility class for decoding Windows current code page data delivered
308 // as a stream of bytes. 308 // as a stream of bytes.
309 class _WindowsCodePageDecoder extends StreamEventTransformer<List<int>, String> { 309 class _WindowsCodePageDecoder extends StreamEventTransformer<List<int>, String> {
310 void handleData(List<int> data, StreamSink<String> sink) { 310 void handleData(List<int> data, StreamSink<String> sink) {
311 sink.add(_decodeBytes(data)); 311 sink.add(_decodeBytes(data));
312 } 312 }
313 313
314 external static String _decodeBytes(List<int> bytes); 314 external static String _decodeBytes(List<int> bytes);
315 } 315 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698