| From: | Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com> | 
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> | 
| Cc: | Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Joel Jacobson <joel(at)compiler(dot)org> | 
| Subject: | Re: Another regexp performance improvement: skip useless paren-captures | 
| Date: | 2021-08-10 01:17:40 | 
| Message-ID: | CD86BE1C-C5F9-4AC5-A932-B26CC5F1FE15@enterprisedb.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
> On Aug 9, 2021, at 6:11 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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 in the 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Noah Misch | 2021-08-10 01:23:07 | Re: replay of CREATE TABLESPACE eats data at wal_level=minimal | 
| Previous Message | Tom Lane | 2021-08-10 01:11:14 | Re: Another regexp performance improvement: skip useless paren-captures |