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

Unified Diff: runtime/bin/socket_stream.dart

Issue 8506005: Merge the two buffer list implementations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from ager@ Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/buffer_list.dart ('k') | runtime/bin/string_stream.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_stream.dart
diff --git a/runtime/bin/socket_stream.dart b/runtime/bin/socket_stream.dart
index 4dfa6e38f31535197cc136d419fc8ad381305de9..e3d0d725a3fae66337efbfd6e6965932ad4a6034 100644
--- a/runtime/bin/socket_stream.dart
+++ b/runtime/bin/socket_stream.dart
@@ -54,55 +54,9 @@ class SocketInputStream implements InputStream {
}
-class _BufferList2 {
- _BufferList2() {
- clear();
- }
-
- // Adds a new buffer to the list possibly with an offset of the
- // first byte of interest. The offset can only be specified if the
- // buffer list is empty.
- void add(List<int> buffer, [int offset = 0]) {
- assert(offset == 0 || _buffers.isEmpty());
- _buffers.addLast(buffer);
- _length += buffer.length - offset;
- if (offset != 0) _index = offset;
- }
-
- List<int> get first() => _buffers.first();
- int get index() => _index;
-
- void removeBytes(int count) {
- int firstRemaining = first.length - _index;
- assert(count <= firstRemaining);
- if (count == firstRemaining) {
- _buffers.removeFirst();
- _index = 0;
- } else {
- _index += count;
- }
- _length -= count;
- }
-
- int get length() => _length;
-
- bool isEmpty() => _buffers.isEmpty();
-
- void clear() {
- _index = 0;
- _length = 0;
- _buffers = new Queue();
- }
-
- int _length; // Total length of pending data.
- Queue<List<int>> _buffers;
- int _index; // Offset into the first buffer of next write position.
-}
-
-
class SocketOutputStream implements OutputStream {
SocketOutputStream(Socket socket)
- : _socket = socket, _pendingWrites = new _BufferList2() {
+ : _socket = socket, _pendingWrites = new _BufferList() {
_socket.writeHandler = _writeHandler;
_socket.errorHandler = _errorHandler;
}
@@ -199,7 +153,7 @@ class SocketOutputStream implements OutputStream {
}
Socket _socket;
- _BufferList2 _pendingWrites;
+ _BufferList _pendingWrites;
var _noPendingWriteHandler;
var _streamErrorHandler;
bool _closing = false;
« no previous file with comments | « runtime/bin/buffer_list.dart ('k') | runtime/bin/string_stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698