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

Side by Side Diff: sdk/lib/convert/utf.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/convert/byte_conversion.dart ('k') | no next file » | 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 /** The Unicode Replacement character `U+FFFD` (�). */ 7 /** The Unicode Replacement character `U+FFFD` (�). */
8 const int UNICODE_REPLACEMENT_CHARACTER_RUNE = 0xFFFD; 8 const int UNICODE_REPLACEMENT_CHARACTER_RUNE = 0xFFFD;
9 9
10 /** The Unicode Byte Order Marker (BOM) character `U+FEFF`. */ 10 /** The Unicode Byte Order Marker (BOM) character `U+FEFF`. */
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 int _bufferIndex = 0; 127 int _bufferIndex = 0;
128 final List<int> _buffer; 128 final List<int> _buffer;
129 129
130 static const _DEFAULT_BYTE_BUFFER_SIZE = 1024; 130 static const _DEFAULT_BYTE_BUFFER_SIZE = 1024;
131 131
132 _Utf8Encoder() : this.withBufferSize(_DEFAULT_BYTE_BUFFER_SIZE); 132 _Utf8Encoder() : this.withBufferSize(_DEFAULT_BYTE_BUFFER_SIZE);
133 133
134 _Utf8Encoder.withBufferSize(int bufferSize) 134 _Utf8Encoder.withBufferSize(int bufferSize)
135 : _buffer = _createBuffer(bufferSize); 135 : _buffer = _createBuffer(bufferSize);
136 136
137 // TODO(11971): Always use Uint8List.
138 /** 137 /**
139 * Allow an implementation to pick the most efficient way of storing bytes. 138 * Allow an implementation to pick the most efficient way of storing bytes.
140 */ 139 */
141 external static List<int> _createBuffer(int size); 140 static List<int> _createBuffer(int size) => new Uint8List(size);
142 141
143 /** 142 /**
144 * Tries to combine the given [leadingSurrogate] with the [nextCodeUnit] and 143 * Tries to combine the given [leadingSurrogate] with the [nextCodeUnit] and
145 * writes it to [_buffer]. 144 * writes it to [_buffer].
146 * 145 *
147 * Returns true if the [nextCodeUnit] was combined with the 146 * Returns true if the [nextCodeUnit] was combined with the
148 * [leadingSurrogate]. If it wasn't then nextCodeUnit was not a trailing 147 * [leadingSurrogate]. If it wasn't then nextCodeUnit was not a trailing
149 * surrogate and has not been written yet. 148 * surrogate and has not been written yet.
150 * 149 *
151 * It is safe to pass 0 for [nextCodeUnit] in which case only the leading 150 * It is safe to pass 0 for [nextCodeUnit] in which case only the leading
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 } 541 }
543 break loop; 542 break loop;
544 } 543 }
545 if (expectedUnits > 0) { 544 if (expectedUnits > 0) {
546 _value = value; 545 _value = value;
547 _expectedUnits = expectedUnits; 546 _expectedUnits = expectedUnits;
548 _extraUnits = extraUnits; 547 _extraUnits = extraUnits;
549 } 548 }
550 } 549 }
551 } 550 }
OLDNEW
« no previous file with comments | « sdk/lib/convert/byte_conversion.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698