private void writeBytesSlow ( final byte [ ] bytes , int off , int len ) { while ( len > 0 ) { final Block block = current ; final int amount = Math . min ( len , block . remaining ( ) ) ; System . arraycopy ( bytes , off , block . data , block . limit , amount ) ; block . limit += amount ; off += amount ; len -= amount ; if ( block . remaining ( ) == 0 ) { if ( index == blocks . size ( ) - 1 ) { allocateNewBlock ( ) ; } index ++ ; current = blocks . get ( index ) ; } } }
slow in the sense that we do all kind of block boundary checking