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

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

Issue 18031023: Remove _BufferList from dart:io and now use BytesBuilder. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use takeBytes not toBytes. Created 7 years, 5 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/io/buffer_list.dart ('k') | sdk/lib/io/file_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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 /** 60 /**
61 * Returns the contents of `this` and clears `this`. 61 * Returns the contents of `this` and clears `this`.
62 * 62 *
63 * The list returned is a view of the the internal buffer, limited to the 63 * The list returned is a view of the the internal buffer, limited to the
64 * [length]. 64 * [length].
65 */ 65 */
66 List<int> takeBytes() { 66 List<int> takeBytes() {
67 if (_buffer == null) return new Uint8List(0); 67 if (_buffer == null) return new Uint8List(0);
68 var buffer = _buffer; 68 var buffer = _buffer;
69 int length = _length;
69 clear(); 70 clear();
70 return new Uint8List.view(buffer.buffer, 0, _length); 71 return new Uint8List.view(buffer.buffer, 0, length);
Bill Hesse 2013/07/12 10:23:25 Very funny bug!
71 } 72 }
72 73
73 /** 74 /**
74 * Returns a copy of the current contents of the builder. 75 * Returns a copy of the current contents of the builder.
75 * 76 *
76 * Leaves the contents of the builder intact. 77 * Leaves the contents of the builder intact.
77 */ 78 */
78 List<int> toBytes() { 79 List<int> toBytes() {
79 if (_buffer == null) return new Uint8List(0); 80 if (_buffer == null) return new Uint8List(0);
80 return new Uint8List.fromList( 81 return new Uint8List.fromList(
(...skipping 26 matching lines...) Expand all
107 int _pow2roundup(int x) { 108 int _pow2roundup(int x) {
108 --x; 109 --x;
109 x |= x >> 1; 110 x |= x >> 1;
110 x |= x >> 2; 111 x |= x >> 2;
111 x |= x >> 4; 112 x |= x >> 4;
112 x |= x >> 8; 113 x |= x >> 8;
113 x |= x >> 16; 114 x |= x >> 16;
114 return x + 1; 115 return x + 1;
115 } 116 }
116 } 117 }
OLDNEW
« no previous file with comments | « sdk/lib/io/buffer_list.dart ('k') | sdk/lib/io/file_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698