BlockFileLoader: effectively final sizeBytes, dataBytes

When reading blocks from the file stream use two effectively final
`byte[]` rather than reuse a single `byte[]`. This also makes the code
more readable by using more meaningful variable names.
This commit is contained in:
Sean Gilligan 2023-08-12 13:14:11 -07:00 committed by Andreas Schildbach
parent 7776f7c907
commit 2248513489

View File

@ -164,13 +164,13 @@ public class BlockFileLoader implements Iterable<Block> {
if (nextChar == (packetMagic & 0xff))
break;
}
byte[] bytes = new byte[4];
currentFileStream.read(bytes, 0, 4);
long size = ByteUtils.readUint32(bytes, 0);
bytes = new byte[(int) size];
currentFileStream.read(bytes, 0, (int) size);
byte[] sizeBytes = new byte[4];
currentFileStream.read(sizeBytes, 0, 4);
long size = ByteUtils.readUint32(sizeBytes, 0);
byte[] dataBytes = new byte[(int) size];
currentFileStream.read(dataBytes, 0, (int) size);
try {
nextBlock = serializer.makeBlock(ByteBuffer.wrap(bytes));
nextBlock = serializer.makeBlock(ByteBuffer.wrap(dataBytes));
} catch (ProtocolException e) {
nextBlock = null;
} catch (Exception e) {