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

Unified Diff: runtime/bin/socket_impl.dart

Issue 11000025: Revert hiding of VM-only coreimpl list implementation types. While I (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | « runtime/bin/process_impl.dart ('k') | runtime/lib/array.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « runtime/bin/process_impl.dart ('k') | runtime/lib/array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698