| OLD | NEW |
| 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 * Builds a list of bytes, allowing bytes and lists of bytes to be added at the | 8 * Builds a list of bytes, allowing bytes and lists of bytes to be added at the |
| 9 * end. | 9 * end. |
| 10 * | 10 * |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 x |= x >> 4; | 146 x |= x >> 4; |
| 147 x |= x >> 8; | 147 x |= x >> 8; |
| 148 x |= x >> 16; | 148 x |= x >> 16; |
| 149 return x + 1; | 149 return x + 1; |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 | 152 |
| 153 | 153 |
| 154 class _BytesBuilder implements BytesBuilder { | 154 class _BytesBuilder implements BytesBuilder { |
| 155 int _length = 0; | 155 int _length = 0; |
| 156 final List _chunks = []; | 156 final _chunks = <List<int>>[]; |
| 157 | 157 |
| 158 void add(List<int> bytes) { | 158 void add(List<int> bytes) { |
| 159 if (bytes is! Uint8List) { | 159 if (bytes is! Uint8List) { |
| 160 bytes = new Uint8List.fromList(bytes); | 160 bytes = new Uint8List.fromList(bytes); |
| 161 } | 161 } |
| 162 _chunks.add(bytes); | 162 _chunks.add(bytes); |
| 163 _length += bytes.length; | 163 _length += bytes.length; |
| 164 } | 164 } |
| 165 | 165 |
| 166 void addByte(int byte) { add([byte]); } | 166 void addByte(int byte) { add([byte]); } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 197 | 197 |
| 198 bool get isEmpty => _length == 0; | 198 bool get isEmpty => _length == 0; |
| 199 | 199 |
| 200 bool get isNotEmpty => _length != 0; | 200 bool get isNotEmpty => _length != 0; |
| 201 | 201 |
| 202 void clear() { | 202 void clear() { |
| 203 _length = 0; | 203 _length = 0; |
| 204 _chunks.clear(); | 204 _chunks.clear(); |
| 205 } | 205 } |
| 206 } | 206 } |
| OLD | NEW |