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.bugs Subject: bug#60953: The :match predicate with large regexp in tree-sitter font-lock seems inefficient Date: Mon, 30 Jan 2023 17:08:39 +0200 Message-ID: <83mt603vrc.fsf@gnu.org> References: <7624dddc-4600-9a03-ac8b-d3c9e0ab618c@yandex.ru> <04729838-b7d4-8a08-2b71-12536a28aebb@yandex.ru> <83wn5ag4nc.fsf@gnu.org> <01b5d074-fb12-6b1f-cbfb-5e759833b854@yandex.ru> <838rhpg57n.fsf@gnu.org> <5026D975-983F-4D18-8690-BE139C92825D@gmail.com> <83pmb1emxi.fsf@gnu.org> <6f318afc-ca71-8b7e-c822-52e6635b5718@yandex.ru> <83sffxcfxw.fsf@gnu.org> <83pmb1cbg5.fsf@gnu.org> <2da844d3-ea31-289e-2821-aa174e365ffd@yandex.ru> <6784f9e7-844b-374d-2a1e-8a61cebe0d7e@yandex.ru> <83zga03yne.fsf@gnu.org> <373a575f-c683-1581-c3e6-502e9897fb04@yandex.ru> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="585"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, 60953@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 30 16:10:37 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1pMVnk-000AUc-Fm for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 30 Jan 2023 16:10:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pMVnf-0007ez-6t; Mon, 30 Jan 2023 10:10:27 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMVnJ-0007c4-EF for bug-gnu-emacs@gnu.org; Mon, 30 Jan 2023 10:10:06 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pMVnH-0003iC-5U for bug-gnu-emacs@gnu.org; Mon, 30 Jan 2023 10:10:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pMVnH-0006lA-0v for bug-gnu-emacs@gnu.org; Mon, 30 Jan 2023 10:10:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 30 Jan 2023 15:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60953 X-GNU-PR-Package: emacs Original-Received: via spool by 60953-submit@debbugs.gnu.org id=B60953.167509135425864 (code B ref 60953); Mon, 30 Jan 2023 15:10:02 +0000 Original-Received: (at 60953) by debbugs.gnu.org; 30 Jan 2023 15:09:14 +0000 Original-Received: from localhost ([127.0.0.1]:50098 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pMVmT-0006j4-FB for submit@debbugs.gnu.org; Mon, 30 Jan 2023 10:09:13 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:53518) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pMVmS-0006ir-0E for 60953@debbugs.gnu.org; Mon, 30 Jan 2023 10:09:12 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pMVmM-0003Ss-Kk; Mon, 30 Jan 2023 10:09:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=E1PYpnZZSoslwBDvomEqejc+Qjck5tg9K1LIHs0kJ9M=; b=kIy12gUkRhwp ZFAAMDaWa6WRf2nAui/HnAvX+BbwWsxWb6ZLoPyIekshTWM+DRHOD3obWx8NIdOYzvZVh3nYY9wbW i+Yz/5E/9US+o2LDCEnN5KIiN9KoiC1Cc4q141s7/6MgSBW2p24bqnIvgQQu/lvGcWmBnIOK7c5kX dwIFDRjfYXlfQ3knmerzzzaifswNRoafC0mQ8ghft8TK4FXfsI1fA40gmNxzOOPSyav+XB8OxOsk6 wiXKHN8W1CON/7DpSGtr708yOHTR/74HTO5lIv9v8BG18fya45FbOF9nNkvfDc5akRzT0GFbZ9c1o Mea/uLi4VDuu3FC1+pFtxA==; Original-Received: from [87.69.77.57] (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 1pMVmA-00089b-GZ; Mon, 30 Jan 2023 10:09:06 -0500 In-Reply-To: <373a575f-c683-1581-c3e6-502e9897fb04@yandex.ru> (message from Dmitry Gutov on Mon, 30 Jan 2023 16:47:01 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:254444 Archived-At: > Date: Mon, 30 Jan 2023 16:47:01 +0200 > Cc: casouri@gmail.com, 60953@debbugs.gnu.org > From: Dmitry Gutov > > On 30/01/2023 16:06, Eli Zaretskii wrote: > > > But why do you need to narrow there? fast_looking_at will not go > > beyond end_pos/end_byte anyway, there's no need to restrict it. > > The reason for that is to be able to support the \` and \' markers in > REGEXP. I haven't found any alternative approach that doesn't call > 'substring'. fast_looking_at already does an anchored match, so I'm not sure I follow. I don't even understand why you need th \` part, when the match will either always start from the first position or fail. And for \', just compare the length of the match returned by fast_looking_at with the length of the text. What am I missing? > > And here I suggest an additional optimization, since you already know > > the byte positions: > > No real objection from me if you're sure, but I tried that, and the > benchmarks showed no difference. Sheer luck: you force SET_BUF_BEGV etc. to call buf_charpos_to_bytepos for no reason: you already have the byte positions in hand. > (I suppose we also could save the previous values of BEGV_BYTE and > ZV_BYTE to use when restoring.) Yes. > Either way, we would use this *instead of* Fnarrow_to_region, right? Fnarrow_to_region does little else. But I need to understand first why you need to change the restriction.