mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
MemoryOutputStream: Avoid allocating unnecessarily large buffers
Previously, we would allocate storage large enough to fit the entire contents of the input stream, even if this was lower than the maxNumBytesToWrite.
This commit is contained in:
parent
76adebee13
commit
84d4c8794a
1 changed files with 2 additions and 2 deletions
|
|
@ -176,11 +176,11 @@ int64 MemoryOutputStream::writeFromInputStream (InputStream& source, int64 maxNu
|
|||
|
||||
if (availableData > 0)
|
||||
{
|
||||
if (maxNumBytesToWrite > availableData || maxNumBytesToWrite < 0)
|
||||
if (maxNumBytesToWrite < 0 || availableData < maxNumBytesToWrite)
|
||||
maxNumBytesToWrite = availableData;
|
||||
|
||||
if (blockToUse != nullptr)
|
||||
preallocate (position + (size_t) availableData);
|
||||
preallocate (position + (size_t) maxNumBytesToWrite);
|
||||
}
|
||||
|
||||
return OutputStream::writeFromInputStream (source, maxNumBytesToWrite);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue