Subject: Re: bug#21077: 24.5; Slow printing in inferior python buffer with python-shell-enable-font-lock

From: Stefan Monnier <[email-masked]>
Date: Mon, 03 Aug 2015 17:41:24 -0400

>> In the case of comint modes, rather than disable font-lock we should
>> refrain from font-locking the text after the last \n (since that's the
>> line that keeps getting expanded, so we end up re-font-locking it O(N)
>> times for a line of length N, for a total amount of work of O(N^2)).
>> IIRC I have a similar hack in grep.el or compile.el.

> But comint-output-filter does

> (font-lock-prepend-text-property prompt-start (point)
> 					       'font-lock-face
> 					       'comint-highlight-prompt)

> So keyword fontification seems to be inhibited anyway.  Is this done in
> a particularly inefficient way?

That doesn't inhibit keyword fontification per se.  It just makes most
keyword rules ineffective, but the test is done after the hard work
anyway, so in a way yes, it's done in an inefficient way (tho skipping
some keywords by checking font-lock-face would in general be
even more inefficient).

        Stefan