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

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

Issue 1908943004: Fix void foo(..) => ... to use { } instead. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Upload Created 4 years, 8 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
« no previous file with comments | « sdk/lib/convert/string_conversion.dart ('k') | sdk/lib/io/http_impl.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.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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 if (bytes is Uint8List) { 106 if (bytes is Uint8List) {
107 _buffer.setRange(_length, required, bytes); 107 _buffer.setRange(_length, required, bytes);
108 } else { 108 } else {
109 for (int i = 0; i < bytesLength; i++) { 109 for (int i = 0; i < bytesLength; i++) {
110 _buffer[_length + i] = bytes[i]; 110 _buffer[_length + i] = bytes[i];
111 } 111 }
112 } 112 }
113 _length = required; 113 _length = required;
114 } 114 }
115 115
116 void addByte(int byte) => add([byte]); 116 void addByte(int byte) { add([byte]); }
117 117
118 List<int> takeBytes() { 118 List<int> takeBytes() {
119 if (_buffer == null) return new Uint8List(0); 119 if (_buffer == null) return new Uint8List(0);
120 var buffer = new Uint8List.view(_buffer.buffer, 0, _length); 120 var buffer = new Uint8List.view(_buffer.buffer, 0, _length);
121 clear(); 121 clear();
122 return buffer; 122 return buffer;
123 } 123 }
124 124
125 List<int> toBytes() { 125 List<int> toBytes() {
126 if (_buffer == null) return new Uint8List(0); 126 if (_buffer == null) return new Uint8List(0);
(...skipping 29 matching lines...) Expand all
156 final List _chunks = []; 156 final List _chunks = [];
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]); }
167 167
168 List<int> takeBytes() { 168 List<int> takeBytes() {
169 if (_chunks.length == 0) return new Uint8List(0); 169 if (_chunks.length == 0) return new Uint8List(0);
170 if (_chunks.length == 1) { 170 if (_chunks.length == 1) {
171 var buffer = _chunks.single; 171 var buffer = _chunks.single;
172 clear(); 172 clear();
173 return buffer; 173 return buffer;
174 } 174 }
175 var buffer = new Uint8List(_length); 175 var buffer = new Uint8List(_length);
176 int offset = 0; 176 int offset = 0;
(...skipping 20 matching lines...) Expand all
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 }
OLDNEW
« no previous file with comments | « sdk/lib/convert/string_conversion.dart ('k') | sdk/lib/io/http_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698