Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mBeWE-0004zm-Ul for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Aug 2021 14:38:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mBeWD-0008Ka-TI for pgsql-hackers@arkaria.postgresql.org; Thu, 05 Aug 2021 14:38:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mBeU3-00036O-HY for pgsql-hackers@lists.postgresql.org; Thu, 05 Aug 2021 14:36:31 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mBeU1-0002Ml-C6 for pgsql-hackers@lists.postgresql.org; Thu, 05 Aug 2021 14:36:30 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 175EaLhD2390508; Thu, 5 Aug 2021 10:36:21 -0400 From: Tom Lane To: Andrew Dunstan cc: pgsql-hackers@lists.postgresql.org, Joel Jacobson Subject: Re: Another regexp performance improvement: skip useless paren-captures In-reply-to: <31908a04-f73b-8c5b-ed99-919fd4cd4b54@dunslane.net> References: <2219936.1628115334@sss.pgh.pa.us> <31908a04-f73b-8c5b-ed99-919fd4cd4b54@dunslane.net> Comments: In-reply-to Andrew Dunstan message dated "Thu, 05 Aug 2021 09:42:47 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2390506.1628174181.1@sss.pgh.pa.us> Date: Thu, 05 Aug 2021 10:36:21 -0400 Message-ID: <2390507.1628174181@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andrew Dunstan writes: > I'm a bit worried about how you'll keep track of back-ref numbering > since back-refs only count capturing groups, and you're silently turning > a capturing group into a non-capturing group. They're already numbered at this point, and we aren't changing the numbers of the capturing groups that remain live. There will be unused entries in the regmatch_t array at runtime (corresponding to the zapped groups), but that doesn't cost anything worth mentioning. Now that you mention it, I am not sure whether there are any regression test cases that specifically cover still being able to match \2 when the first capture group went away. Probably should add more cases... regards, tom lane