[Top][All Lists]

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

Re: bug-reference-prog-mode slows down CC Mode's scrolling by ~7%

From: Alan Mackenzie
Subject: Re: bug-reference-prog-mode slows down CC Mode's scrolling by ~7%
Date: Thu, 2 Sep 2021 16:57:19 +0000

Hello, Stefan.

On Wed, Sep 01, 2021 at 16:59:02 -0400, Stefan Monnier wrote:
> > However, this mechanism is rendered ineffective if a second function
> > is add-hook'd onto jit-lock-functions.  Maybe this could be fixed,
> > though it looks difficult.

> I think we can "easily" handle this specific case if the
> `bug-reference-prog-mode` function is added to the end of the hook
> rather than to its beginning and use a patch along the lines of the
> one below.

Yes.  How about an optional parameter to jit-lock-register meaning "put
this function at the beginning of jit-lock-functions", with the default
meaning put the function at the end?

I haven't tried it, but I don't think the patch below is quite enough.
I think it needs a (setq beg (min tight-beg beg)), or something like
that, to prevent TIGHT-BEG being set back to the original value of BEG
in the body of jit-lock--run-functions.

> I don't know if it would make any difference to the 7% figure.

I'm sure it would.  That slow down comes from Jit Lock fontifying the
statement straddling a jit chunk border twice.

>         Stefan

> diff --git a/lisp/jit-lock.el b/lisp/jit-lock.el
> index a905936b6b9..14d09c979b9 100644
> --- a/lisp/jit-lock.el
> +++ b/lisp/jit-lock.el
> @@ -390,7 +390,7 @@ jit-lock--run-functions
>       'jit-lock-functions
>       (lambda (fun)
>         (pcase-let*
> -           ((res (funcall fun beg end))
> +           ((res (funcall fun (or tight-beg beg) (tight-end end)))
>              (`(,this-beg . ,this-end)
>               (if (eq (car-safe res) 'jit-lock-bounds)
>                   (cdr res) (cons beg end))))

Alan Mackenzie (Nuremberg, Germany).

reply via email to

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