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

Unified Diff: lib/io/socket_stream_impl.dart

Issue 11338037: Start reading data from sockets directly into external byte arrays (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from ager@ Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/io/socket.dart ('k') | runtime/bin/builtin_impl_sources.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/io/socket_stream_impl.dart
diff --git a/lib/io/socket_stream_impl.dart b/lib/io/socket_stream_impl.dart
index e56334c5c94732045a734f20ab211a9aafe2a6da..c8799b1ba7da7cf9d22d21f7e669890ec83a09bd 100644
--- a/lib/io/socket_stream_impl.dart
+++ b/lib/io/socket_stream_impl.dart
@@ -9,30 +9,7 @@ class _SocketInputStream implements InputStream {
}
List<int> read([int len]) {
- int bytesToRead = available();
- if (bytesToRead == 0) return null;
- if (len !== null) {
- if (len <= 0) {
- throw new StreamException("Illegal length $len");
- } else if (bytesToRead > len) {
- bytesToRead = len;
- }
- }
- List<int> buffer = new Uint8List(bytesToRead);
- int bytesRead = _socket.readList(buffer, 0, bytesToRead);
- if (bytesRead == 0) {
- // On MacOS when reading from a tty Ctrl-D will result in one
- // byte reported as available. Attempting to read it out will
- // result in zero bytes read. When that happens there is no data
- // which is indicated by a null return value.
- return null;
- } else if (bytesRead < bytesToRead) {
- List<int> newBuffer = new Uint8List(bytesRead);
- newBuffer.setRange(0, bytesRead, buffer);
- return newBuffer;
- } else {
- return buffer;
- }
+ return _socket.read(len);
}
int readInto(List<int> buffer, [int offset = 0, int len]) {
« no previous file with comments | « lib/io/socket.dart ('k') | runtime/bin/builtin_impl_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698