From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: cc-mode fontification feels random Date: Fri, 04 Jun 2021 22:26:39 +0300 Message-ID: <83im2tl9cg.fsf@gnu.org> References: <831r9iw473.fsf@gnu.org> <2d6d1cb0-2e8f-ceea-cb83-3bb840b65115@dancol.org> <83zgw6udxt.fsf@gnu.org> <87czt1zzns.fsf@gmail.com> <371647e9-9508-ae98-26f0-3649d7ba114e@dancol.org> <83o8clla1u.fsf@gnu.org> <179d874d918.2816.cc5b3318d7e9908e2c46732289705cb0@dancol.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1660"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, monnier@iro.umontreal.ca, joaotavora@gmail.com To: Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jun 04 21:27:20 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lpFTU-0000Er-Gz for ged-emacs-devel@m.gmane-mx.org; Fri, 04 Jun 2021 21:27:20 +0200 Original-Received: from localhost ([::1]:42404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpFTT-0006WE-JQ for ged-emacs-devel@m.gmane-mx.org; Fri, 04 Jun 2021 15:27:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpFSw-0005pr-4Z for emacs-devel@gnu.org; Fri, 04 Jun 2021 15:26:46 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:48292) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lpFSv-0001PP-U9; Fri, 04 Jun 2021 15:26:45 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2823 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lpFSv-0008Qw-EI; Fri, 04 Jun 2021 15:26:45 -0400 In-Reply-To: <179d874d918.2816.cc5b3318d7e9908e2c46732289705cb0@dancol.org> (message from Daniel Colascione on Fri, 04 Jun 2021 12:16:47 -0700) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:270402 Archived-At: > From: Daniel Colascione > CC: , , > Date: Fri, 04 Jun 2021 12:16:47 -0700 > > > I 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. > 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. Even if eventually we need to use a memory copy, that'll run circles around buffer-substring, and will avoid triggering GC. > 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.