private void calculateChunkedSums ( byte [ ] data , int dataOffset , int dataLength , byte [ ] sums , int sumsOffset ) { int remaining = dataLength ; while ( remaining > 0 ) { int n = Math . min ( remaining , bytesPerChecksum ) ; summer . reset ( ) ; summer . update ( data , dataOffset , n ) ; dataOffset += n ; remaining -= n ; long calculated = summer . getValue ( ) ; sums [ sumsOffset ++ ] = ( byte ) ( calculated >> 24 ) ; sums [ sumsOffset ++ ] = ( byte ) ( calculated >> 16 ) ; sums [ sumsOffset ++ ] = ( byte ) ( calculated >> 8 ) ; sums [ sumsOffset ++ ] = ( byte ) ( calculated ) ; } }
Implementation of chunked calculation specifically on byte arrays . This is to avoid the copy when dealing with ByteBuffers that have array backing .