| Index: runtime/bin/socket_impl.dart
|
| diff --git a/runtime/bin/socket_impl.dart b/runtime/bin/socket_impl.dart
|
| index 3cd2c770f1cc6a8b7de41ace2b18d256f6beb8f4..49654130d1132e1aeac09c08c10343097025d226 100644
|
| --- a/runtime/bin/socket_impl.dart
|
| +++ b/runtime/bin/socket_impl.dart
|
| @@ -404,8 +404,28 @@ class _Socket extends _SocketBase implements Socket {
|
| if ((offset + bytes) > buffer.length) {
|
| throw new IndexOutOfRangeException(offset + bytes);
|
| }
|
| - var fastBuffer = _ensureFastAndSerializableBuffer(buffer, offset, bytes);
|
| - var result = _writeList(fastBuffer[0], fastBuffer[1], bytes);
|
| + // When using the Dart C API to access raw data, using a ByteArray is
|
| + // currently much faster. This function will make a copy of the
|
| + // supplied List to a ByteArray if it isn't already.
|
| + List outBuffer;
|
| + int outOffset = offset;
|
| + if (buffer is Uint8List || buffer is ObjectArray) {
|
| + outBuffer = buffer;
|
| + } else {
|
| + outBuffer = new Uint8List(bytes);
|
| + outOffset = 0;
|
| + int j = offset;
|
| + for (int i = 0; i < bytes; i++) {
|
| + int value = buffer[j];
|
| + if (value is! int) {
|
| + throw new FileIOException(
|
| + "List element is not an integer at index $j");
|
| + }
|
| + outBuffer[i] = value;
|
| + j++;
|
| + }
|
| + }
|
| + var result = _writeList(outBuffer, outOffset, bytes);
|
| if (result is OSError) {
|
| _reportError(result, "Write failed");
|
| // If writing fails we return 0 as the number of bytes and
|
|
|