> On May 13, 2022, at 5:04 PM, Yuan Fu wrote: > > > >> On May 13, 2022, at 3:41 AM, Eli Zaretskii wrote: >> >>> From: Yoav Marco >>> Cc: casouri@gmail.com, emacs-devel@gnu.org >>> Date: Fri, 13 May 2022 11:42:04 +0300 >>> >>> Eli Zaretskii writes: >>> >>>> Is it true that there's just one query for each PL mode, and it is >>>> fixed (doesn't change) and doesn't depend on the buffer contents in >>>> any way? If that is true, the major mode could compile the query >>>> whenever it is initialized, and then reuse it in every buffer that is >>>> under that major mode. >>> >>> It's correct, though there might be more than one if a mode wants to >>> offer fontification options users can toggle. But yeah, the major mode >>> could compile its queries when initialized. I'm in favor of this too. >> >> Then let's do that. Yuan, are there any issues with implementing >> this? > > No, it’s fairly straightforward. Added to todo-list ;-) I’ve added support for compiling queries. Try this new benchmark that I’ve attached. You can see three forms, each for tree-sitter, tree-sitter compiled, and font-lock. The compiled one should be fairly fast. I haven’t wrote benchmarks that can be added to tests yet. Yuan