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

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

Issue 12655003: Buffer the entire http header to one packet, and buffer other data in chunks of 4-16 kb. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | « no previous file | sdk/lib/io/http_headers.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 part of dart.io; 5 part of dart.io;
6 6
7 /** 7 /**
8 * Utility class that holds a number of byte buffers and can deliver 8 * Utility class that holds a number of byte buffers and can deliver
9 * the bytes either one by one or in chunks. 9 * the bytes either one by one or in chunks.
10 */ 10 */
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 _buffers.removeFirst(); 59 _buffers.removeFirst();
60 _index = 0; 60 _index = 0;
61 } 61 }
62 return value; 62 return value;
63 } 63 }
64 64
65 /** 65 /**
66 * Read [count] bytes from the buffer list. If the number of bytes 66 * Read [count] bytes from the buffer list. If the number of bytes
67 * requested is not available null will be returned. 67 * requested is not available null will be returned.
68 */ 68 */
69 List<int> readBytes(int count) { 69 List<int> readBytes([int count]) {
70 if (count == null) count = length;
70 List<int> result; 71 List<int> result;
71 if (_length == 0 || _length < count) return null; 72 if (_length == 0 || _length < count) return null;
72 if (_index == 0 && _buffers.first.length == count) { 73 if (_index == 0 && _buffers.first.length == count) {
73 result = _buffers.first; 74 result = _buffers.first;
74 _buffers.removeFirst(); 75 _buffers.removeFirst();
75 _index = 0; 76 _index = 0;
76 _length -= count; 77 _length -= count;
77 return result; 78 return result;
78 } else { 79 } else {
79 int firstRemaining = _buffers.first.length - _index; 80 int firstRemaining = _buffers.first.length - _index;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 void clear() { 151 void clear() {
151 _index = 0; 152 _index = 0;
152 _length = 0; 153 _length = 0;
153 _buffers = new Queue(); 154 _buffers = new Queue();
154 } 155 }
155 156
156 int _length; // Total number of bytes remaining in the buffers. 157 int _length; // Total number of bytes remaining in the buffers.
157 Queue<List<int>> _buffers; // List of data buffers. 158 Queue<List<int>> _buffers; // List of data buffers.
158 int _index; // Index of the next byte in the first buffer. 159 int _index; // Index of the next byte in the first buffer.
159 } 160 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/io/http_headers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698