Diffusion KIO d2d52da38016

Avoid QByteArray::remove in AccessManagerReply::readData

Authored by fvogt on Sep 11 2018, 1:22 PM.

Description

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

Details

Committed
fvogtSep 22 2018, 4:23 PM
Reviewer
svuorela
Differential Revision
D15426: Avoid QByteArray::remove in AccessManagerReply::readData
Parents
R241:6c02509a9fbf: GIT_SILENT s/KDE/KIO/ in a comment
Branches
Unknown
Tags
Unknown