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

Unified Diff: runtime/bin/socket_impl.dart

Issue 10990055: Hide VM-only coreimpl List implementation types. These should not be (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: x64 as well, sigh. 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
Index: runtime/bin/socket_impl.dart
diff --git a/runtime/bin/socket_impl.dart b/runtime/bin/socket_impl.dart
index 49654130d1132e1aeac09c08c10343097025d226..3cd2c770f1cc6a8b7de41ace2b18d256f6beb8f4 100644
--- a/runtime/bin/socket_impl.dart
+++ b/runtime/bin/socket_impl.dart
@@ -404,28 +404,8 @@ class _Socket extends _SocketBase implements Socket {
if ((offset + bytes) > buffer.length) {
throw new IndexOutOfRangeException(offset + 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);
+ var fastBuffer = _ensureFastAndSerializableBuffer(buffer, offset, bytes);
+ var result = _writeList(fastBuffer[0], fastBuffer[1], bytes);
if (result is OSError) {
_reportError(result, "Write failed");
// If writing fails we return 0 as the number of bytes and

Powered by Google App Engine
This is Rietveld 408576698