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

Unified Diff: runtime/bin/socket_stream.dart

Issue 8493002: Change the default for the len argument to writeFrom on OutputStream (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/output_stream.dart ('k') | tests/standalone/src/EchoServerStreamTest.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 195186b6b035ce76cdc045517e55a148cab9e42f..af8c8aaa594664b6e6cf537bea6f8701ef21fe41 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 = true]) {
+ 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);
}
}
« no previous file with comments | « runtime/bin/output_stream.dart ('k') | tests/standalone/src/EchoServerStreamTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698