Skip to content
Permalink
Browse files
Optimize MultiBlobInputStream.read()
Previously this allocated a byte array for every call.
  • Loading branch information
gaul committed Aug 1, 2020
1 parent 9c21bf2 commit 3ea2cce5f2942153f8c51d39ec2444e4e19dcbdc
Showing 1 changed file with 14 additions and 5 deletions.
@@ -1010,12 +1010,21 @@ private static final class MultiBlobInputStream extends InputStream {

@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

0 comments on commit 3ea2cce

Please sign in to comment.