From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#60953: The :match predicate with large regexp in tree-sitter font-lock seems inefficient Date: Wed, 1 Feb 2023 17:15:43 +0200 Message-ID: <85293540-cc52-1535-eb8b-85adf646c016@yandex.ru> References: <7624dddc-4600-9a03-ac8b-d3c9e0ab618c@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> <83mt603vrc.fsf@gnu.org> <83e58a1b-2e4a-356a-36d8-c756ff105b62@yandex.ru> <83bkmf52va.fsf@gnu.org> <33cad4c1-4af5-37bb-05bc-79a4d9c1a700@yandex.ru> <83wn533lut.fsf@gnu.org> <19892f55-498e-1109-2229-2ddd984849a4@yandex.ru> <83tu073ksp.fsf@gnu.org> <83sffr2xq2.fsf@gnu.org> <83zg9xzg35.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33763"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Cc: casouri@gmail.com, 60953@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 01 16:16:30 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 1pNEqa-0008dK-4g for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 01 Feb 2023 16:16:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNEqU-0006G3-3d; Wed, 01 Feb 2023 10:16:22 -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 1pNEqA-000683-Bx for bug-gnu-emacs@gnu.org; Wed, 01 Feb 2023 10:16:03 -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 1pNEqA-0004Hf-2z for bug-gnu-emacs@gnu.org; Wed, 01 Feb 2023 10:16:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pNEq9-0001D0-Uf for bug-gnu-emacs@gnu.org; Wed, 01 Feb 2023 10:16:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 01 Feb 2023 15:16:01 +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.16752645544628 (code B ref 60953); Wed, 01 Feb 2023 15:16:01 +0000 Original-Received: (at 60953) by debbugs.gnu.org; 1 Feb 2023 15:15:54 +0000 Original-Received: from localhost ([127.0.0.1]:59626 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNEq1-0001CZ-TF for submit@debbugs.gnu.org; Wed, 01 Feb 2023 10:15:54 -0500 Original-Received: from mail-ej1-f53.google.com ([209.85.218.53]:44013) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNEpz-0001CL-6Y for 60953@debbugs.gnu.org; Wed, 01 Feb 2023 10:15:52 -0500 Original-Received: by mail-ej1-f53.google.com with SMTP id mc11so29862849ejb.10 for <60953@debbugs.gnu.org>; Wed, 01 Feb 2023 07:15:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=jYXlKai+v24f9CvrcPXvjUu2TE94Y3TpFEQWFAkVg3I=; b=OfvcIrCrR812wLdc5Io9ZZFegUOPYDjQP9bhRsDq27SaDfpyps311maRkokfyfIs5+ 1zxHnBtJ0ALfi8D5X8H4GwW4apKhbsu6rifU9fdhUxH1xpEbH/5ipDSxwtJDP5SYx3cK +5Wj4Iz2tZ9I3/hB6JZUbX4IU2mkHKr+LTGVgKK8Yy3Q2H3X3nHFQJA1+sDxHe7rxX2v im+EFpOHpE0T2P9uPTF07zCwYz8bpt15AfzrSKuoU1LzP81cUg6MrF6fH3jddP9Blb7a B0d5LZIXf7jn616/W8D028tbRA78vGZnXsmBH9CmK8qcp/P97cgp5bEho4M2KLaM+hRZ dQkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jYXlKai+v24f9CvrcPXvjUu2TE94Y3TpFEQWFAkVg3I=; b=c1cVcUEoU5vOaFpoxiuCgtZO7eQvbrvirDc9mx3LPCWj6MsWy4wmeyZMId4bSNdpEy 6S7kFP5Z6zoEJ1+mmxEETjUOxiDScfJ0eR8YypSOdfYr5E0bW1tdsIkG1Jq4VJhkIIU+ 21P4Fl5Qq4TAHP0JuP7I8y3WLTFFF8Kgf098nVvIeuUSYg2xJI3BI5IbpNdSDjIqZhci 93okA88iL3Im/FSY2QTyPJBO0/ChxFmPsmr1gIgeKuLRhkbjzDcvexmRJ+wyWUtlFtgP hBAwARyh0DdXm1rVvWBoXPGBLu2svZLbm120FZNLyz+jGx2GfUAlmljb1CI18Cu+vLEu GF1g== X-Gm-Message-State: AO0yUKXDAnwox0Pm8mHs9MzCwX6+LIRTiEOwusRp2U5fZ1i0GvDUuZyf iIEIla0tYAQsXcX3JrPqed8= X-Google-Smtp-Source: AK7set9VgUNa23ky7Mf2o4C2T2ITfAZ8cOzoDlepAmJAdiTepdx21k6LAp9enIeb5DJFgDVBXWkaSQ== X-Received: by 2002:a17:906:8a63:b0:888:7ce4:1dc1 with SMTP id hy3-20020a1709068a6300b008887ce41dc1mr2823022ejc.26.1675264545292; Wed, 01 Feb 2023 07:15:45 -0800 (PST) Original-Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id h15-20020a170906584f00b00886ec4f2fc7sm5866902ejs.17.2023.02.01.07.15.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Feb 2023 07:15:44 -0800 (PST) Content-Language: en-US In-Reply-To: <83zg9xzg35.fsf@gnu.org> 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:254588 Archived-At: On 01/02/2023 15:10, Eli Zaretskii wrote: >> Date: Tue, 31 Jan 2023 20:16:01 +0200 >> Cc: casouri@gmail.com, 60953@debbugs.gnu.org >> From: Dmitry Gutov >> >>> Can you describe what that function should do? I don't think I have a >>> clear idea of that. >> >> In Lisp that function could be implemented as >> >> (defun buffer-substring-match (regexp &optional start end >> inhibit-modify) >> (string-match regexp >> (buffer-substring (or start (point-min)) >> (or end (point-max))) >> inhibit-modify)) >> >> Meaning, it matches the regexp against the buffer substring, with the >> string-start and string-end anchors working. >> >> But it would be implemented in C, meaning we could avoid the extra >> consing and funcall overhead. > > Now I'm confused, because I thought the C functions we were > considering all fit the above description. Except they don't match \` and \' at START and END. Only at actual point-min and point-max. I suppose the new function could be implemented with narrowing as well. If we decide it's the best method. >> Anyway, it seems like it might be too late as an addition to Emacs 29. >> And we can implement the match predicate using narrowing for this >> release, to be updated later. > > Right, this is not a catastrophe, IMO. The work on TS-based modes is > just beginning. I also don't see any particular slowdown from altering BEGV and ZV in C. So the current method might be the fastest possible anyway.