2004-04-21 Michael Koch <konqueror@gmx.de>
authorMichael Koch <konqueror@gmx.de>
Wed, 21 Apr 2004 15:33:53 +0000 (15:33 +0000)
committerMichael Koch <mkoch@gcc.gnu.org>
Wed, 21 Apr 2004 15:33:53 +0000 (15:33 +0000)
* java/nio/DirectByteBufferImpl.java
(shiftDown): Made static, give address as argument and
provide a convenience method that overwrites shiftDown in
ByteBufferImpl and calls the native shiftDown.
* java/nio/MappedByteBufferImpl.java
(): Use optimized method in DirectByteBufferImpl.
* java/nio/natDirectByteBufferImpl.cc
(shiftDown): Changed method signature. Removed usage of array_offset.

From-SVN: r80967

libjava/ChangeLog
libjava/java/nio/DirectByteBufferImpl.java
libjava/java/nio/MappedByteBufferImpl.java
libjava/java/nio/natDirectByteBufferImpl.cc

index 04c0876b87910df1cab182b3d3a29d508e9580b5..56bcc3278645bdd9fab2939df2ede30f51ea5740 100644 (file)
@@ -1,3 +1,14 @@
+2004-04-21  Michael Koch  <konqueror@gmx.de>
+
+       * java/nio/DirectByteBufferImpl.java
+       (shiftDown): Made static, give address as argument and
+       provide a convenience method that overwrites shiftDown in
+       ByteBufferImpl and calls the native shiftDown.
+       * java/nio/MappedByteBufferImpl.java
+       (): Use optimized method in DirectByteBufferImpl.
+       * java/nio/natDirectByteBufferImpl.cc
+       (shiftDown): Changed method signature. Removed usage of array_offset.
+
 2004-04-21  Michael Koch  <konqueror@gmx.de>
 
        * gnu/java/net/natPlainSocketImplPosix.cc
index 7c2b783d7d8c3903fbec6c5f052c44b435b19b2b..be0fc52c07d7d7fc90bffbb15200279e46138dd2 100644 (file)
@@ -136,15 +136,20 @@ final class DirectByteBufferImpl extends ByteBuffer
     return this;
   }
   
-  native void shiftDown (int dst_offset, int src_offset, int count);
+  static native void shiftDown(RawData address, int dst_offset, int src_offset, int count);
 
+  void shiftDown(int dst_offset, int src_offset, int count)
+  {
+    shiftDown(address, dst_offset, src_offset, count);
+  }
+  
   public ByteBuffer compact ()
   {
     int pos = position();
     if (pos > 0)
       {
        int count = remaining();
-       shiftDown(0, pos, count);
+       shiftDown(address, 0, pos, count);
        position(count);
        limit(capacity());
       }
index ccd987edfbd7c6aa941cca34ad47cadb2a0a04df..5932c99f6d02fd5cd929c5236854e38c54fc28ee 100644 (file)
@@ -121,7 +121,8 @@ final class MappedByteBufferImpl extends MappedByteBuffer
     if (pos > 0)
       {
        int count = remaining();
-       shiftDown(0, pos, count);
+       // Call shiftDown method optimized for direct buffers.
+       DirectByteBufferImpl.shiftDown(address, 0, pos, count);
        position(count);
        limit(capacity());
       }
index 94225c3988521e3d3d1b83343b3433035e0a6854..88f53fc2bea844a06d461cdf8cb15c011e0c1456 100644 (file)
@@ -65,9 +65,9 @@ java::nio::DirectByteBufferImpl::adjustAddress (RawData* address, jint offset)
 
 void
 java::nio::DirectByteBufferImpl::shiftDown
-(jint dst_offset, jint src_offset, jint count)
+(RawData* address, jint dst_offset, jint src_offset, jint count)
 {
-  jbyte* dst = reinterpret_cast<jbyte*> (address) + array_offset + dst_offset;
-  jbyte* src = reinterpret_cast<jbyte*> (address) + array_offset + src_offset;
+  jbyte* dst = reinterpret_cast<jbyte*> (address) + dst_offset;
+  jbyte* src = reinterpret_cast<jbyte*> (address) + src_offset;
   ::memmove(dst, src, count);
 }