emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tree-sitter integration on feature/tree-sitter (severe performance i


From: Yuan Fu
Subject: Re: Tree-sitter integration on feature/tree-sitter (severe performance issues together with linum-mode)
Date: Thu, 18 Aug 2022 02:44:47 -0700

> 
> Can something be done to Yuan's code to make it perform equally to 
> Thuan-Anh's? Are there improvements which can be done to linum-mode to avoid 
> these kinds of issues?
> 
> I know for sure I'm not qualified to answer those questions, but I think it's 
> definitely something which needs to be looked into and if anyone has anything 
> they want me to provide feedback on though, I will be more than happy test 
> those changes and report back.

Good news, the slowness can be easily resolved by compiling the query pattern 
in csharp-mode-font-lock-settings-1 (this is a recent addition to treesit). I 
guess typescript-mode’s query pattern is short enough to not bog down 
font-locking, but C#’s relatively large set of patterns makes query captures 
very slow.

I changed

(setq csharp-mode-font-lock-settings-1
      `((c-sharp
         (
           ;; Various constructs
           (comment)  @font-lock-comment-face
           (modifier) @font-lock-keyword-face
           (this_expression) @font-lock-keyword-face
           (escape_sequence) @font-lock-keyword-face
           …

to

(setq csharp-mode-font-lock-settings-1
      `((c-sharp
         ,(treesit-query-compile
           'c-sharp
           '(
             ;; Various constructs
             (comment)  @font-lock-comment-face
             (modifier) @font-lock-keyword-face
             (this_expression) @font-lock-keyword-face
             (escape_sequence) @font-lock-keyword-face
             …

And now csharp-mode is pretty fast!

Yuan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]