Re: Another regexp performance improvement: skip useless paren-captures - Mailing list pgsql-hackers

From Mark Dilger
Subject Re: Another regexp performance improvement: skip useless paren-captures
Date
Msg-id CD86BE1C-C5F9-4AC5-A932-B26CC5F1FE15@enterprisedb.com
Whole thread Raw
In response to Re: Another regexp performance improvement: skip useless paren-captures  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Another regexp performance improvement: skip useless paren-captures  (Mark Dilger <mark.dilger@enterprisedb.com>)
List pgsql-hackers

> On Aug 9, 2021, at 6:11 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Hm.  I'm not sure that this example proves anything about Perl's handling
> of the situation, since you didn't use a backref.

Well, this doesn't die either:

if ('foo' =~ m/((??{ die; })(.)(??{ die $1; })){0}((??{ die "got here"; })|\2)/)
{
    print "matched\n";
}

The point is that the regex engine never walks the part of the pattern that {0} qualifies.  I thought it was more clear
inthe prior example, because that example proves that the engine does get as far as capturing.  This example also does
that,and with a backref, because it dies with "got here". 

—
Mark Dilger
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company






pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Another regexp performance improvement: skip useless paren-captures
Next
From: Noah Misch
Date:
Subject: Re: replay of CREATE TABLESPACE eats data at wal_level=minimal