FileStream: seek only when length exceeds buffer size

This commit is contained in:
Daniel Chabrowski 2022-10-09 03:12:42 +02:00 committed by Urs Fleisch
parent 9914519d43
commit 2e90ec0ef0

View File

@ -206,9 +206,12 @@ ByteVector FileStream::readBlock(unsigned long length)
if(length == 0)
return ByteVector();
const unsigned long streamLength = static_cast<unsigned long>(FileStream::length());
if(length > bufferSize() && length > streamLength)
length = streamLength;
if(length > bufferSize()) {
const unsigned long streamLength = static_cast<unsigned long>(FileStream::length());
if(length > streamLength) {
length = streamLength;
}
}
ByteVector buffer(static_cast<unsigned int>(length));