Don't shuffle input buffer unless actually needed
This commit is contained in:
committed by
Lauri Kasanen
parent
25995e2490
commit
a55f142c98
@@ -51,12 +51,14 @@ bool BufferedInStream::overrun(size_t needed, bool wait)
|
|||||||
"requested size of %lu bytes exceeds maximum of %lu bytes",
|
"requested size of %lu bytes exceeds maximum of %lu bytes",
|
||||||
(long unsigned)needed, (long unsigned)bufSize);
|
(long unsigned)needed, (long unsigned)bufSize);
|
||||||
|
|
||||||
if (end - ptr != 0)
|
// Do we need to shuffle things around?
|
||||||
|
if ((bufSize - (ptr - start)) < needed) {
|
||||||
memmove(start, ptr, end - ptr);
|
memmove(start, ptr, end - ptr);
|
||||||
|
|
||||||
offset += ptr - start;
|
offset += ptr - start;
|
||||||
end -= ptr - start;
|
end -= ptr - start;
|
||||||
ptr = start;
|
ptr = start;
|
||||||
|
}
|
||||||
|
|
||||||
while (avail() < needed) {
|
while (avail() < needed) {
|
||||||
if (!fillBuffer(start + bufSize - end, wait))
|
if (!fillBuffer(start + bufSize - end, wait))
|
||||||
|
|||||||
Reference in New Issue
Block a user