Chromium Code Reviews| Index: runtime/bin/socket_stream.dart |
| diff --git a/runtime/bin/socket_stream.dart b/runtime/bin/socket_stream.dart |
| index 195186b6b035ce76cdc045517e55a148cab9e42f..db635fc7afda73b97500635fd9f2ca9b8e9a1943 100644 |
| --- a/runtime/bin/socket_stream.dart |
| +++ b/runtime/bin/socket_stream.dart |
| @@ -107,12 +107,13 @@ class SocketOutputStream implements OutputStream { |
| _socket.errorHandler = _errorHandler; |
| } |
| - bool write(List<int> buffer) { |
| - return _write(buffer, 0, buffer.length, false); |
| + bool write(List<int> buffer, [bool copyBuffer = false]) { |
|
Mads Ager (google)
2011/11/07 09:18:34
Ah, it is actually false by default. Update commen
Søren Gjesse
2011/11/08 09:31:53
Changed to default to be true (as stated in the co
|
| + return _write(buffer, 0, buffer.length, copyBuffer); |
| } |
| bool writeFrom(List<int> buffer, [int offset = 0, int len]) { |
| - return _write(buffer, offset, (len == null) ? buffer.length : len, true); |
| + return _write( |
| + buffer, offset, (len == null) ? buffer.length - offset : len, true); |
| } |
| void close() { |
| @@ -149,7 +150,6 @@ class SocketOutputStream implements OutputStream { |
| bool _write(List<int> buffer, int offset, int len, bool copyBuffer) { |
| if (_closing || _closed) throw new StreamException("Stream closed"); |
| - if (len == null) len = buffer.length; |
| int bytesWritten = 0; |
| if (_pendingWrites.isEmpty()) { |
| // If nothing is buffered write as much as possible and buffer |
| @@ -159,12 +159,14 @@ class SocketOutputStream implements OutputStream { |
| } |
| // Place remaining data on the pending writes queue. |
| + int notWrittenOffset = offset + bytesWritten; |
| if (copyBuffer) { |
| List<int> newBuffer = |
| - buffer.getRange(offset + bytesWritten, buffer.length); |
| + buffer.getRange(notWrittenOffset, len - bytesWritten); |
| _pendingWrites.add(newBuffer); |
| } else { |
| - _pendingWrites.add(buffer, bytesWritten); |
| + assert(offset + len = buffer.length); |
| + _pendingWrites.add(buffer, notWrittenOffset); |
| } |
| } |