harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r936687 - /harmony/enhanced/java/trunk/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileChannelImpl.java
Date Thu, 22 Apr 2010 09:38:11 GMT
Author: hindessm
Date: Thu Apr 22 09:38:11 2010
New Revision: 936687

URL: http://svn.apache.org/viewvc?rev=936687&view=rev
Log:
Make FileChannelImpl.write(...) more like SocketChannelImpl.write(...).

Modified:
    harmony/enhanced/java/trunk/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileChannelImpl.java

Modified: harmony/enhanced/java/trunk/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileChannelImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileChannelImpl.java?rev=936687&r1=936686&r2=936687&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileChannelImpl.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/FileChannelImpl.java
Thu Apr 22 09:38:11 2010
@@ -583,14 +583,20 @@ public abstract class FileChannelImpl ex
         for (int i = 0; i < length; i++) {
             ByteBuffer buffer = buffers[i + offset];
             if (!buffer.isDirect()) {
-                ByteBuffer directBuffer = ByteBuffer.allocateDirect(buffer
-                        .remaining());
-                int oldPosition = buffer.position();
-                directBuffer.put(buffer);
-                buffer.position(oldPosition);
-                directBuffer.flip();
-                src[i] = directBuffer;
-                offsets[i] = 0;
+                if (buffer.hasArray()) {
+                    src[i] = buffer.array();
+                    lengths[i] = buffer.remaining();
+                    offsets[i] = buffer.position();
+                } else {
+                    ByteBuffer directBuffer = ByteBuffer.allocateDirect(buffer
+                            .remaining());
+                    int oldPosition = buffer.position();
+                    directBuffer.put(buffer);
+                    buffer.position(oldPosition);
+                    directBuffer.flip();
+                    src[i] = directBuffer;
+                    offsets[i] = 0;
+                }
             } else {
                 src[i] = buffer;
                 offsets[i] = buffer.position();



Mime
View raw message