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: Thu, 2 Feb 2023 19:53:07 +0200 Message-ID: <64482032-87e4-f239-82b1-29c68aa22f06@yandex.ru> References: <7624dddc-4600-9a03-ac8b-d3c9e0ab618c@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> <30b047a9-dfe3-948a-a123-2e15221c239d@yandex.ru> <83tu05zeqe.fsf@gnu.org> <957c7e3e-830e-0a03-562f-fdddc6bd1c06@yandex.ru> <835yckzic7.fsf@gnu.org> <835yckxi29.fsf@gnu.org> <88a57446-f89e-9b5e-5e8d-3c3b952ced41@yandex.ru> <83pmasvuzs.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="15946"; 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 Thu Feb 02 18:54:25 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 1pNdmz-00041C-3d for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 Feb 2023 18:54:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNdmg-0002K1-Em; Thu, 02 Feb 2023 12:54:06 -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 1pNdmd-0002JD-JW for bug-gnu-emacs@gnu.org; Thu, 02 Feb 2023 12:54: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 1pNdmd-0000rv-0k for bug-gnu-emacs@gnu.org; Thu, 02 Feb 2023 12:54:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pNdmc-0003vc-89 for bug-gnu-emacs@gnu.org; Thu, 02 Feb 2023 12:54:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 Feb 2023 17:54: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.167536039715046 (code B ref 60953); Thu, 02 Feb 2023 17:54:02 +0000 Original-Received: (at 60953) by debbugs.gnu.org; 2 Feb 2023 17:53:17 +0000 Original-Received: from localhost ([127.0.0.1]:35727 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNdlt-0003ub-Ba for submit@debbugs.gnu.org; Thu, 02 Feb 2023 12:53:17 -0500 Original-Received: from mail-ed1-f51.google.com ([209.85.208.51]:34363) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pNdlr-0003uO-FH for 60953@debbugs.gnu.org; Thu, 02 Feb 2023 12:53:15 -0500 Original-Received: by mail-ed1-f51.google.com with SMTP id z11so2857546ede.1 for <60953@debbugs.gnu.org>; Thu, 02 Feb 2023 09:53:15 -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=sn2CxQ0TWdCT3Sj7VyO0pbuhIS1qwtyOykoVdI8Hkuw=; b=drMJSA0zxjK88Vp0agu/362zg7khMW/703ZXFxWRSDheLa4LBF94akYCxH3V8IWt37 +8QO47zh4aggCzd2OqXyLWjRNl7BwlqMUXW06uycGb6lRSDsrO61Jtf5jltSv7g8rOSY cj6SPb/4KCBNaIp8oluc4JoAEuEYz5TFggRRhCIjI3/sx28iQRJOJZsd7WcDUrQg/v2O Zkx3JiqO3TjeCVXOLXn5G7PubV3jiK7vQGu3j8JfRh+4UEwE+vEaRBDKUhrAeyDIjKAM KaH6UJS/cYvX9yedQ/lj6WiwAZF0UJWP7ZVTkZSiCryuP04LQ2VZ+n3et5rO2QGP0mL8 eG+A== 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=sn2CxQ0TWdCT3Sj7VyO0pbuhIS1qwtyOykoVdI8Hkuw=; b=iyJL93CdBIIx9DPCkBONArzO3VIDhrLWaWc0v607NGXhxqFMi9IC+cIPza1HarktPD L+jdgV9el79nhAYRlXUKKKHfxhYQJEolkBddNiN/+LP4rErRKHAeAEeL8k1LSsbONbeL QBFMOGCFQClQ9q96jDnqIClX8WbRdITyxvz6VOV2MxiDDtmQjMZov6p8Z5SN/pLXJmpx 7t0jiQj6HT1NAEb22Q051Xm6ms0Fzvk0gDPbI3Bcfm1i6oQrkbUz33jKlfHngwwP0Vtu H16ZcUFR19R0xBDlVgMaCcl/yV0DDzr8LozLlu5T29ALKT/gbTuWHcZ+vwcnafcw567X AnCA== X-Gm-Message-State: AO0yUKX5oJbKghoDtViLD8sTwaJDYOd50yjnCbMo/Ayc/rAILuaMWndF uwmn1Vm8WdfTTPW+3rBpNmU= X-Google-Smtp-Source: AK7set/+6UJcRtXzztFoAD8BT1yZwU/6G01cuj1qwmtuBRvLe7dSAswWWMvEGJsZ6jmw0UljMDxmbQ== X-Received: by 2002:a50:99dc:0:b0:497:d4ca:457d with SMTP id n28-20020a5099dc000000b00497d4ca457dmr7526068edb.34.1675360389558; Thu, 02 Feb 2023 09:53:09 -0800 (PST) Original-Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id b12-20020a056402350c00b0049e210884dasm19973edd.15.2023.02.02.09.53.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Feb 2023 09:53:08 -0800 (PST) Content-Language: en-US In-Reply-To: <83pmasvuzs.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:254681 Archived-At: On 02/02/2023 19:26, Eli Zaretskii wrote: >> Date: Thu, 2 Feb 2023 19:03:52 +0200 >> Cc: casouri@gmail.com, 60953@debbugs.gnu.org >> From: Dmitry Gutov >> >>> One gotcha: fast_looking_at returns the length of the match, whereas >>> search_buffer returns the buffer position where it matched. Shouldn't >>> this need a different handling of the return value? >> >> Probably not: we just need to know whether it matched or not. And when >> it did not, it returns 0, right? So the same check should work. > > Which check? if (val > 0) return true; else return false; The :match predicate is just supposed to check whether the regexp matches the node text. It doesn't do anything with the position of the match. > If the search fails, search_buffer returns a non-positive integer, not > zero. That should work too. As long as it never returns 0 for success. Which seems to be confirmed by the check if (np <= 0) ... signal error inside search_command.