[XmlExtractor] Use QXmlStreamReader for better performance
ClosedPublic

Authored by bruns on Nov 1 2018, 4:02 PM.

Details

Summary

At least in the benchmark, QXmlStreamReader is more than twice as fast
as QDomDocument.

Test Plan

Before/after:
RESULT : XmlExtractorTests::benchMarkXmlExtractor():

810 msecs per iteration (total: 810, iterations: 1)

RESULT : XmlExtractorTests::benchMarkXmlExtractor():

288 msecs per iteration (total: 288, iterations: 1)

Diff Detail

Repository
R286 KFileMetaData
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
bruns created this revision.Nov 1 2018, 4:02 PM
Restricted Application added projects: Frameworks, Baloo. · View Herald TranscriptNov 1 2018, 4:02 PM
Restricted Application added subscribers: Baloo, kde-frameworks-devel. · View Herald Transcript
bruns requested review of this revision.Nov 1 2018, 4:02 PM
astippich added inline comments.Nov 2 2018, 8:14 PM
autotests/xmlextractortest.cpp
70

why is there a difference?

bruns marked an inline comment as done.Nov 2 2018, 9:05 PM
bruns added inline comments.
autotests/xmlextractortest.cpp
70

QDomElement::text() leaves a final trailing whitespace which is not trimmed.

apol added a subscriber: apol.Nov 2 2018, 11:44 PM

Patch looks good overall +1

autotests/xmlextractortest.cpp
70

Won't this break any use?

bruns marked 2 inline comments as done.Nov 3 2018, 3:16 AM
bruns added inline comments.
autotests/xmlextractortest.cpp
70

Previously, the last element was "foo_bar__", now it is "foo_bar_".
SimpleExtractionResult::append(text) adds a space after the inserted text after each call.
If there is something sensitive to multiple whitespaces, we have a problem - but I really doubt it.

apol accepted this revision.Nov 4 2018, 1:16 AM
This revision is now accepted and ready to land.Nov 4 2018, 1:16 AM
This revision was automatically updated to reflect the committed changes.
bruns marked an inline comment as done.