Avoid QByteArray::remove in AccessManagerReply::readData
Summary:
If m_data contains a relatively large amount of data, calls to readData are
really expensive as it copies the remaining data around in memory.
For some reason, readAll() on an AccessManagerReply results in calls to
readData with a maxSize of 16384 until it returns 0. That's pretty much the
worst case scenario, but also the most likely used one.
Avoid the expensive remove operation by only calling remove if it saves
sufficient memory.
CCBUG: 375765
Additionally, bail out if maxSize is < 0.
Test Plan:
Ran accessmanagertest, passes.
Downloaded files with kio-gdrive, not stuck in memmove anymore.
It still dies for very large files, but that's a design issue in kio-gdrive
which can't be addressed in KIO.
Reviewers: Frameworks, elvisangelaccio, dfaure, svuorela
Reviewed By: svuorela
Subscribers: svuorela, ngraham, bruns, kde-frameworks-devel
Tags: Frameworks
Differential Revision: https://phabricator.kde.org/D15426