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

Side by Side Diff: sdk/lib/utf/utf16.dart

Issue 11416240: Address Ivan's comments. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Fix typos Created 8 years 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/isolate/base.dart ('k') | sdk/lib/utf/utf32.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 5
6 /** 6 /**
7 * Decodes the UTF-16 bytes as an iterable. Thus, the consumer can only convert 7 * Decodes the UTF-16 bytes as an iterable. Thus, the consumer can only convert
8 * as much of the input as needed. Determines the byte order from the BOM, 8 * as much of the input as needed. Determines the byte order from the BOM,
9 * or uses big-endian as a default. This method always strips a leading BOM. 9 * or uses big-endian as a default. This method always strips a leading BOM.
10 * Set the [replacementCodepoint] to null to throw an ArgumentError 10 * Set the [replacementCodepoint] to null to throw an ArgumentError
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 } 208 }
209 } 209 }
210 210
211 typedef _ListRangeIterator _CodeUnitsProvider(); 211 typedef _ListRangeIterator _CodeUnitsProvider();
212 212
213 /** 213 /**
214 * Return type of [decodeUtf16AsIterable] and variants. The Iterable type 214 * Return type of [decodeUtf16AsIterable] and variants. The Iterable type
215 * provides an iterator on demand and the iterator will only translate bytes 215 * provides an iterator on demand and the iterator will only translate bytes
216 * as requested by the user of the iterator. (Note: results are not cached.) 216 * as requested by the user of the iterator. (Note: results are not cached.)
217 */ 217 */
218 // TODO(floitsch): Consider removing the extend and switch to implements since
219 // that's cheaper to allocate.
218 class IterableUtf16Decoder extends Iterable<int> { 220 class IterableUtf16Decoder extends Iterable<int> {
219 final _CodeUnitsProvider codeunitsProvider; 221 final _CodeUnitsProvider codeunitsProvider;
220 final int replacementCodepoint; 222 final int replacementCodepoint;
221 223
222 IterableUtf16Decoder._(this.codeunitsProvider, this.replacementCodepoint); 224 IterableUtf16Decoder._(this.codeunitsProvider, this.replacementCodepoint);
223 225
224 Utf16CodeUnitDecoder get iterator => 226 Utf16CodeUnitDecoder get iterator =>
225 new Utf16CodeUnitDecoder.fromListRangeIterator(codeunitsProvider(), 227 new Utf16CodeUnitDecoder.fromListRangeIterator(codeunitsProvider(),
226 replacementCodepoint); 228 replacementCodepoint);
227 } 229 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 } 355 }
354 356
355 int decode() { 357 int decode() {
356 utf16EncodedBytesIterator.moveNext(); 358 utf16EncodedBytesIterator.moveNext();
357 int lo = utf16EncodedBytesIterator.current; 359 int lo = utf16EncodedBytesIterator.current;
358 utf16EncodedBytesIterator.moveNext(); 360 utf16EncodedBytesIterator.moveNext();
359 int hi = utf16EncodedBytesIterator.current; 361 int hi = utf16EncodedBytesIterator.current;
360 return (hi << 8) + lo; 362 return (hi << 8) + lo;
361 } 363 }
362 } 364 }
OLDNEW
« no previous file with comments | « sdk/lib/isolate/base.dart ('k') | sdk/lib/utf/utf32.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698