src/java/org/apache/cassandra/utils/ByteBufferUtil.java
/**
     * Transfer bytes from one ByteBuffer to another.
     * This function acts as System.arrayCopy() but for ByteBuffers.
     *
     * @param src the source ByteBuffer
     * @param srcPos starting position in the source ByteBuffer
     * @param dst the destination ByteBuffer
     * @param dstPos starting position in the destination ByteBuffer
     * @param length the number of bytes to copy
     */
Transfer bytes from one ByteBuffer to another.
This function acts as System.arrayCopy() but for ByteBuffers.


Transfer bytes from one ByteBuffer to another . This function acts as System . arrayCopy () but for ByteBuffers .
public static void arrayCopy(ByteBuffer src, int srcPos, ByteBuffer dst, int dstPos, int length)
    {
        if (src.hasArray() && dst.hasArray())
        {
            System.arraycopy(src.array(),
                             src.arrayOffset() + srcPos,
                             dst.array(),
                             dst.arrayOffset() + dstPos,
                             length);
        }
        else
        {
            if (src.limit() - srcPos < length || dst.limit() - dstPos < length)
                throw new IndexOutOfBoundsException();
            for (int i = 0; i < length; i++)
                dst.put(dstPos++, src.get(srcPos++));
        }
    }
public static void arrayCopy ( ByteBuffer src , int srcPos , ByteBuffer dst , int dstPos , int length ) { if ( src . hasArray ( ) && dst . hasArray ( ) ) { System . arraycopy ( src . array ( ) , src . arrayOffset ( ) + srcPos , dst . array ( ) , dst . arrayOffset ( ) + dstPos , length ) ; } else { if ( src . limit ( ) - srcPos < length || dst . limit ( ) - dstPos < length ) throw new IndexOutOfBoundsException ( ) ; for ( int i = 0 ; i < length ; i ++ ) dst . put ( dstPos ++ , src . get ( srcPos ++ ) ) ; } }
Transfer bytes from one ByteBuffer to another.
Transfer bytes from one ByteBuffer to another .
// TODO: ByteBuffer.put is polymorphic, and might be slow here