mirror of https://github.com/apache/jclouds.git
Optimize MultiBlobInputStream.read()
Previously this allocated a byte array for every call.
This commit is contained in:
parent
9c21bf2cc2
commit
3ea2cce5f2
|
@ -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) {
|
||||
while (true) {
|
||||
if (current == null) {
|
||||
if (!blobs.hasNext()) {
|
||||
return -1;
|
||||
}
|
||||
return b[0] & 0x000000FF;
|
||||
current = blobs.next().getPayload().openStream();
|
||||
}
|
||||
int result = current.read();
|
||||
if (result == -1) {
|
||||
current.close();
|
||||
current = null;
|
||||
continue;
|
||||
}
|
||||
return result & 0x000000FF;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue