Optimize parsing headers
ClosedPublic

Authored by dvratil on Oct 11 2017, 1:55 PM.

Details

Summary

Reduce the amount of allocations by not resizing the 'head' bytearray
after extracting each header.

Diff Detail

Repository
R180 PIM: KMime
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
dvratil created this revision.Oct 11 2017, 1:55 PM
Restricted Application added a project: KDE PIM. · View Herald TranscriptOct 11 2017, 1:55 PM
Restricted Application added a subscriber: KDE PIM. · View Herald Transcript

Do we have autotest for it, as it's a big changes.
not sure that we can create some autotests for it.

All the existing unit-tests pass, and since this code is executed whenever KMime::Content::parse() is called it would show up in most of the tests.

vkrause accepted this revision.Oct 13 2017, 3:47 PM

LGTM. A possible further optimization might be trying to avoid the QByteArray::fromRawString calls, as they also allocate (the dptr of the QByteArray, not the actual data).

This revision is now accepted and ready to land.Oct 13 2017, 3:47 PM
This revision was automatically updated to reflect the committed changes.

LGTM. A possible further optimization might be trying to avoid the QByteArray::fromRawString calls, as they also allocate (the dptr of the QByteArray, not the actual data).

@vkrause The only way I see is to change the relevant APIs to have a const char* + size_t overload - is that what you meant?

Yep, exactly. QByteArrayView would address this too, but that's still a long way out.