Optimize MultiBlobInputStream.read()

Previously this allocated a byte array for every call.
This commit is contained in:
Andrew Gaul 2020-07-25 16:39:04 +09:00 committed by Andrew Gaul
parent 9c21bf2cc2
commit 3ea2cce5f2
1 changed files with 14 additions and 5 deletions

View File

@ -1010,12 +1010,21 @@ public final class LocalBlobStore implements BlobStore {
@Override
public int read() throws IOException {
byte[] b = new byte[1];
int result = read(b, 0, b.length);
if (result == -1) {
return -1;
while (true) {
if (current == null) {
if (!blobs.hasNext()) {
return -1;
}
current = blobs.next().getPayload().openStream();
}
int result = current.read();
if (result == -1) {
current.close();
current = null;
continue;
}
return result & 0x000000FF;
}
return b[0] & 0x000000FF;
}
@Override