This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: java.nio.DirectBufferImpl.shiftDown()
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Cc: Per Bothner <per at bothner dot com>
- Date: Wed, 21 Apr 2004 14:05:25 +0200
- Subject: Patch: java.nio.DirectBufferImpl.shiftDown()
Hi list,
On request of some people using java.nio with JNI I made
java.nio.DirectBufferImpl.shiftDown() static and removed an unecessary
usage of array_offset which is always 0 for direct buffers and is
intended only for buffers with backend arrays.
Per: whats your opinion about this ?
Okay to commit to trunk ?
Michael
2004-04-21 Michael Koch <konqueror@gmx.de>
* java/nio/DirectByteBufferImpl.java
(shiftDown): Made static, give address as argument.
* java/nio/natDirectByteBufferImpl.cc
(shiftDown): Changed method signature. Removed usage of array_offset.
Index: java/nio/DirectByteBufferImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/DirectByteBufferImpl.java,v
retrieving revision 1.9
diff -u -r1.9 DirectByteBufferImpl.java
--- java/nio/DirectByteBufferImpl.java 20 Apr 2004 14:54:37 -0000 1.9
+++ java/nio/DirectByteBufferImpl.java 21 Apr 2004 12:00:46 -0000
@@ -136,7 +136,7 @@
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);
public ByteBuffer compact ()
{
@@ -144,7 +144,7 @@
if (pos > 0)
{
int count = remaining();
- shiftDown(0, pos, count);
+ shiftDown(address, 0, pos, count);
position(count);
limit(capacity());
}
Index: java/nio/natDirectByteBufferImpl.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/natDirectByteBufferImpl.cc,v
retrieving revision 1.4
diff -u -r1.4 natDirectByteBufferImpl.cc
--- java/nio/natDirectByteBufferImpl.cc 16 Feb 2004 20:00:33 -0000 1.4
+++ java/nio/natDirectByteBufferImpl.cc 21 Apr 2004 12:00:46 -0000
@@ -65,9 +65,9 @@
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);
}