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

Unified Diff: runtime/bin/socket_impl.dart

Issue 9235067: Use ByteArray's native for Socket and File. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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
Index: runtime/bin/socket_impl.dart
===================================================================
--- runtime/bin/socket_impl.dart (revision 3811)
+++ 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 a 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.
+ List outBuffer;
int outOffset = offset;
- if (buffer is ObjectArray) {
+ if (buffer is ByteArray || buffer is ObjectArray) {
outBuffer = buffer;
} else {
- outBuffer = new ObjectArray(bytes);
+ outBuffer = new ByteArray(bytes);
outOffset = 0;
int j = offset;
for (int i = 0; i < bytes; i++) {
- outBuffer[i] = buffer[j];
+ int value = buffer[j];
+ if (value is! int) {
+ throw new FileIOException(
+ "List element is not an integer at index $j");
+ }
+ outBuffer[i] = value;
j++;
}
}

Powered by Google App Engine
This is Rietveld 408576698