Patch: java.nio.DirectBufferImpl.shiftDown()

Michael Koch konqueror@gmx.de
Wed Apr 21 15:17:00 GMT 2004


Am Mittwoch, 21. April 2004 15:50 schrieb Per Bothner:
> Michael Koch wrote:
> > 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 ?
>
> But what about a ShortViewBufferImpl that is created by calling
> asShortBuffer on a DirectBufferImpl?  You're now using the slow
> shiftDown implementation in ByteBuffer instead of the much
> faster native method.
>
> Why do some implementations need DirectBufferImpl.shiftDown to
> be static?

It was requested because its much more easy to implement in JNI.

> A possible solution:  To your patch add to DirectBufferImpl:
>
> void shiftDown (int dst_offset, int src_offset, int count)
> {
>    shiftDown(address, dst_offset, srd_offset, count);
> }
>
> Same thing in MappedByteBuffer:
>
> void shiftDown (int dst_offset, int src_offset, int count)
> {
>    DirectByteBufferImpl.shiftDown(address, dst_offset, srd_offset,
> count); }

Thx for the hint. I added this to the patch.
Ok for commit ?


Michael


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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: nio.diff
Type: text/x-diff
Size: 2493 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20040421/272c423d/attachment.bin>


More information about the Java-patches mailing list