summaryrefslogtreecommitdiff
path: root/ext/pcre/php_pcre.h
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-03-19 13:06:21 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-03-19 13:06:21 +0100
commit4fe3d108af2b0a1e8810959fe1ea7a0b52291ad7 (patch)
treec6325dd574d98e6fa37987af558e08f5b932fe4b /ext/pcre/php_pcre.h
parent38b16274d16f3a90dd42e340b8429041c6aa7365 (diff)
downloadphp-git-4fe3d108af2b0a1e8810959fe1ea7a0b52291ad7.tar.gz
Don't create a new array for empty/null match every time
If PREG_OFFSET_CAPTURE is used, unmatched subpatterns will be either [null, -1] or ['', -1] depending on PREG_UNMATCHED_AS_NULL mode. Instead of creating a new array like this every time, cache it inside a global (per-request -- could make it immutable though). Additionally check whether the subpattern is an empty string or single character string and use an existing interned string in that case. Empty / single-char subpatterns are common, so let's avoid allocating strings for them.
Diffstat (limited to 'ext/pcre/php_pcre.h')
-rw-r--r--ext/pcre/php_pcre.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/ext/pcre/php_pcre.h b/ext/pcre/php_pcre.h
index 0377ce77a8..eca3ca5fdf 100644
--- a/ext/pcre/php_pcre.h
+++ b/ext/pcre/php_pcre.h
@@ -75,6 +75,9 @@ ZEND_BEGIN_MODULE_GLOBALS(pcre)
zend_bool jit;
#endif
int error_code;
+ /* Used for unmatched subpatterns in OFFSET_CAPTURE mode */
+ zval unmatched_null_pair;
+ zval unmatched_empty_pair;
ZEND_END_MODULE_GLOBALS(pcre)
PHPAPI ZEND_EXTERN_MODULE_GLOBALS(pcre)