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

Unified Diff: runtime/bin/socket_impl.dart

Issue 9254022: Make sure to use an ObjectArray when writing to a socket (Closed) Base URL: https://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
« runtime/bin/file_impl.dart ('K') | « runtime/bin/file_impl.dart ('k') | no next file » | 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 b462dadc11f98a23eb191ccef6c8a9c640422344..bea81fdeda9c931c06a11d268c0611c5acdf0023 100644
--- a/runtime/bin/socket_impl.dart
+++ b/runtime/bin/socket_impl.dart
@@ -1,4 +1,4 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -322,7 +322,23 @@ class _Socket extends _SocketBase implements Socket {
if ((offset + bytes) > buffer.length) {
throw new IndexOutOfRangeException(offset + bytes);
}
- var bytes_written = _writeList(buffer, offset, bytes);
+ ObjectArray outBuffer;
+ int outOffset = offset;
+ if (buffer is ObjectArray) {
+ outBuffer = buffer;
+ } else {
+ // When using the Dart C API access to ObjectArray by index is
Mads Ager (google) 2012/01/19 08:38:25 Please move the comment to the same place as in th
Søren Gjesse 2012/01/19 08:45:14 Done.
+ // currently much faster. This function will make a *copy* of
+ // the supplied List to an ObjectArray if it isn't already.
+ outBuffer = new ObjectArray(bytes);
+ outOffset = 0;
+ int j = offset;
+ for (int i = 0; i < bytes; i++) {
+ outBuffer[i] = buffer[j];
+ j++;
+ }
+ }
+ var bytes_written = _writeList(outBuffer, outOffset, bytes);
if (bytes_written < 0) {
// If writing fails we return 0 as the number of bytes and
// report the error on the error handler.
« runtime/bin/file_impl.dart ('K') | « runtime/bin/file_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698