precompute attribute format for context & rules
ClosedPublic

Authored by cullmann on Sep 1 2018, 3:36 PM.

Details

Summary

avoid costly lookup, e.g. 3% of runtime of highlighting

simplifies the highlightLine stuff, as we only need to keep track of format changes,
not lookup contexts in addition

fixes that we don't see that formats change if name is equal in different
definitions

accessors are inline, the classes are internal anyways

Test Plan

make && make test

updated references, now we properly applyFormat if we walk from one into a other
definition with same name formats

Diff Detail

Repository
R216 Syntax Highlighting
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 2415
Build 2433: arc lint + arc unit
cullmann created this revision.Sep 1 2018, 3:36 PM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptSep 1 2018, 3:36 PM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
cullmann requested review of this revision.Sep 1 2018, 3:36 PM
cullmann updated this revision to Diff 40826.Sep 1 2018, 3:44 PM

inline MatchResult, very often used, no need to waste time for calls

fix scoping in Repository::definitionForMimeType

I inlined the MatchResult, it is used the whole time and given it is purely internal, one doesn't need to waste cycles for having calls to get the two ints and the reference to the stringlist.
The implicit constructor now doesn't play around with the stringlist either.

vkrause accepted this revision.Sep 1 2018, 4:06 PM
This revision is now accepted and ready to land.Sep 1 2018, 4:06 PM
This revision was automatically updated to reflect the committed changes.
cullmann reopened this revision.Sep 1 2018, 4:26 PM

Hmm, tests are unstable :/
I did run them here now X times, they are stable. Perhaps depending on which highlightings got parsed in which order.
Why should then the id's be equal for different definitions?

e.g.

QDEBUG : TestHighlighterTest::testHighlight(test.py) Using syntax "Python"

  • "/home/jenkins/workspace/Frameworks syntax-highlighting kf5-qt5 SUSEQt5.9/autotests/reference/test.py.ref" 2018-09-01 16:10:03.327043830 +0000

+++ "/home/jenkins/workspace/Frameworks syntax-highlighting kf5-qt5 SUSEQt5.9/build/autotests/output/test.py.ref" 2018-09-01 16:13:08.885670252 +0000
@@ -1,6 +1,6 @@
-<Comment>#</Comment><Comment> comment with </Comment><Alert Level 1>ALERT</Alert Level 1><br/>
+<Comment># comment with </Comment><Alert Level 1>ALERT</Alert Level 1><br/>
<Normal Text></Normal Text><br/>
-<Comment>'''</Comment><Comment> multiline</Comment><br/>
+<Comment>''' multiline</Comment><br/>
<Comment> comment</Comment><br/>
<Comment> </Comment><Alert Level 3>###</Alert Level 3><br/>
<Comment> '''</Comment><br/>

This revision is now accepted and ready to land.Sep 1 2018, 4:26 PM
This revision was automatically updated to reflect the committed changes.

:=)

The second lookup round over all included rules in the context did really hide some things.

Now we properly keep track which context is needed to be used for the lookup.

2321fc443483fb5669f9092980c7ab25bf78778d
7af02d6b955ef60ac7e9666b2694c461500d52bc