Tune KeywordList lookup & avoid allocations for implicit capture group
ClosedPublic

Authored by cullmann on Sep 2 2018, 11:03 AM.

Details

Summary

No longer any allocations, we use sorted vectors for lookup.
Init sorted vectors lazy, but no longer as lazy that mutable members are needed.

Test Plan

make && make test works
perf looks nicer afterwards

Diff Detail

Repository
R216 Syntax Highlighting
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
cullmann created this revision.Sep 2 2018, 11:03 AM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptSep 2 2018, 11:03 AM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
cullmann requested review of this revision.Sep 2 2018, 11:03 AM

perf before:

perf after the change

And yes, the skip offset lookup is still deadly ;=)

8.27%     8.27%  highlighter_ben  libKF5SyntaxHighlighting.so.5.50.0  [.] QHash<KSyntaxHighlighting::Rule*, int>::findNode
cullmann updated this revision to Diff 40852.Sep 2 2018, 11:34 AM

Avoid saving the implicit capture group 0 on each regex match.
That avoids allocating the match string each time (and the non-empty list).
One anyways shall only access capture group >= 1

cullmann retitled this revision from Tune KeywordList lookup to Tune KeywordList lookup & avoid allocations for implicit capture group.Sep 2 2018, 11:34 AM

Now the QRegularExpression::match call is the real offender allocation wise.

vkrause accepted this revision.Sep 2 2018, 2:49 PM
This revision is now accepted and ready to land.Sep 2 2018, 2:49 PM
This revision was automatically updated to reflect the committed changes.