|
From: | Daniel Colascione |
Subject: | Re: cc-mode fontification feels random |
Date: | Fri, 04 Jun 2021 12:33:25 -0700 |
User-agent: | AquaMail/1.29.2-1810 (build: 102900008) |
On June 4, 2021 12:26:47 PM Eli Zaretskii <eliz@gnu.org> wrote:
From: Daniel Colascione <dancol@dancol.org> CC: <monnier@iro.umontreal.ca>, <joaotavora@gmail.com>, <emacs-devel@gnu.org> Date: Fri, 04 Jun 2021 12:16:47 -0700I see no reason for copying, nor for making these tools aware of the gap. At least tree-sitter allows the application to provide a function through which tree-sitter will access the edited text. It should be simple to write such a function, because on the C level we always know where the gap is.So you propose providing a "char get_buffer_char(size_t POS)" function? That *is* copying If you run that over all values of POS, all you've done is make a slow and shitty memcpy.What do you think tree-sitter does with the fast copy you hand to it? doesn't it walk it one character at a time? And if you studied the tree-sitter's internals, and it uses get_buffer_char as a means of copying text into its own buffer, then perhaps we could ask tree-sitter developers to avoid the copy and use the text directly.
Teaching TS to use a generic cursor interface would be great.
So you want to amortize the call over several characters? Okay. Now you've reinvented buffer-substring.buffer-substring is not just a copy of a chunk of text, it's much more.
The variant without text properties doesn't do much.
Even if eventually we need to use a memory copy, that'll run circles around buffer-substring, and will avoid triggering GC.
Sure. I'm not opposed to adding an API that's basically a more efficient buffer substring for C callers. I'm just pointing out that the idea of giving TS "direct access" to a buffer without any copy at all doesn't make a lot of sense.
Because any kind of "access" to the buffer that doesn't expose the gap is going to be a copy anyway.The regexp routines aren't.
The regexp routines have Emacs specific knowledge. My argument doesn't apply to code we can customize for Emacs.
[Prev in Thread] | Current Thread | [Next in Thread] |