Chromium Code Reviews| Index: runtime/bin/socket_impl.dart |
| =================================================================== |
| --- runtime/bin/socket_impl.dart (revision 3706) |
| +++ runtime/bin/socket_impl.dart (working copy) |
| @@ -306,19 +306,24 @@ |
| if ((offset + bytes) > buffer.length) { |
| throw new IndexOutOfRangeException(offset + bytes); |
| } |
| - // When using the Dart C API access to ObjectArray by index is |
| + // When using the Dart C API to access raw data, using ByteArray is |
| // currently much faster. This function will make a copy of the |
| - // supplied List to an ObjectArray if it isn't already. |
| - ObjectArray outBuffer; |
| + // supplied List to a ByteArray if it isn't already. |
| + ByteArray outBuffer; |
| int outOffset = offset; |
| - if (buffer is ObjectArray) { |
| + if (buffer is ByteArray) { |
| outBuffer = buffer; |
| } else { |
|
Ivan Posva
2012/02/01 01:12:41
ditto
Anders Johnsen
2012/02/01 02:12:11
(see comment to file_impl.dart)
|
| - outBuffer = new ObjectArray(bytes); |
| + outBuffer = new ByteArray(bytes); |
| outOffset = 0; |
| int j = offset; |
| for (int i = 0; i < bytes; i++) { |
| - outBuffer[i] = buffer[j]; |
| + try { |
| + outBuffer[i] = buffer[j]; |
| + } catch (IllegalArgumentException e) { |
| + throw const SocketIOException( |
| + "List element is not an integer in byte range"); |
| + } |
| j++; |
| } |
| } |