mirror of
https://github.com/xerial/snappy-java.git
synced 2025-07-20 12:34:30 +02:00
Use non-JNI method for read(byte[])
This commit is contained in:
parent
29bfc49473
commit
00f53c49e4
@ -157,10 +157,27 @@ public class SnappyInputStream
|
|||||||
* @see java.io.InputStream#read(byte[], int, int)
|
* @see java.io.InputStream#read(byte[], int, int)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int read(byte[] b, int off, int len)
|
public int read(byte[] b, int byteOffset, int byteLength)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
return rawRead(b, off, len);
|
int writtenBytes = 0;
|
||||||
|
for (; writtenBytes < byteLength; ) {
|
||||||
|
|
||||||
|
if (uncompressedCursor >= uncompressedLimit) {
|
||||||
|
if (hasNextChunk()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return writtenBytes == 0 ? -1 : writtenBytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int bytesToWrite = Math.min(uncompressedLimit - uncompressedCursor, byteLength - writtenBytes);
|
||||||
|
System.arraycopy(uncompressed, uncompressedCursor, b, byteOffset + writtenBytes, bytesToWrite);
|
||||||
|
writtenBytes += bytesToWrite;
|
||||||
|
uncompressedCursor += bytesToWrite;
|
||||||
|
}
|
||||||
|
|
||||||
|
return writtenBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user