[php-src] Issue #14423: Cache PCRE named group names
| From: | mvorisek | Date: | Sat, 01 Jun 2024 21:33:50 +0000 |
| Subject: | [php-src] Issue #14423: Cache PCRE named group names | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-247013@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/14423
Author: mvorisek
### Description
I have discovered PCRE
preg_match is at least twice as slow when using named groups.
PCRE internally remaps named groups to indexes, so the slowdown is comming from php-src.
I belive the reason is the named group names zvals are created each time the preg_match
is run.
I propose to improve the performance by caching the names zvals in the regex cache entry - https://github.com/php/php-src/blob/php-8.3.7/ext/pcre/php_pcre.c#L55