This is the mail archive of the mailing list for the Java project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH to use ByteBufferHelper more

On Sat, Feb 07, 2004 at 09:58:37AM -0800, Per Bothner wrote:
> Michael Koch wrote:
> >>+  void shiftDown (int dst_offset, int src_offset, int count)
> >>+  {
> >>+    for (int i = 0; i < count; i++)
> >>+      put(dst_offset + i, get(src_offset + i));
> >>+  }
> >
> >
> >As far as I could see this method is called for moving data in non-direct 
> >buffers.
> >It would be nice to use System.arrayCopy. This makes the code more
> >ovious I think.
> It don't think that would be correct for the abstract ByteBuffer, but I
> added such an implementation for ByteBufferImpl:
>   void shiftDown (int dst_offset, int src_offset, int count)
>   {
>     System.arraycopy(backing_buffer, array_offset + src_offset,
> 		     backing_buffer, array_offset + dst_offset,
> 		     count);
>   }
> I noticed what looks like a bug:  Shouldn't the get/put methods in
> ByteBufferImpl add the array_offset to the index?  There may be
> other places where use of array_offset should be reviewed.

Yeah, array_offset is probably not honored enough because its normally
zero and I dont tested that enough.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]