D28039: optimize dynamic regex matching

Milian Wolff noreply at phabricator.kde.org
Sat Mar 14 07:47:17 GMT 2020


mwolff added a comment.


  Let me try to explain the skip offset idea (it's been years since I came up with this in GeSHi :) )
  
  A code highlighter will repeatedly ask all highlight contexts and items therein to find the closest token to highlight next to the current cursor position.
  The closest token will win and then the highlighter will repeat its question at the position after the token.
  For regular expressions, it's often cheaper (as indicated by this patch once again), to match the line once starting from the current position and then remember where the first match - if any - is in the current line.
  Then, the next time the highlighter asks for a token position, we can check the last matched position. This is essentially the skip offset - i.e. we know that we can skip querying the regexp again until the cursor position is beyond the next match.
  
  Dominik, does this clear things up?

REPOSITORY
  R216 Syntax Highlighting

BRANCH
  master

REVISION DETAIL
  https://phabricator.kde.org/D28039

To: cullmann, dhaumann, vkrause, nibags
Cc: mwolff, kwrite-devel, kde-frameworks-devel, rrosch, LeGast00n, cblack, GB_2, domson, michaelh, ngraham, bruns, demsking, cullmann, sars, dhaumann
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kwrite-devel/attachments/20200314/7270805c/attachment.html>


More information about the KWrite-Devel mailing list