summaryrefslogtreecommitdiff
path: root/ext/pcre/php_pcre.c
diff options
context:
space:
mode:
authortwosee <twose@qq.com>2020-06-08 18:45:01 +0800
committerNikita Popov <nikita.ppv@gmail.com>2020-06-08 15:31:52 +0200
commit83a77015ad0dcd25d30342a08cbc8ec3de077305 (patch)
tree3039af88d8bb809f98698bc4bcb282da9f374a14 /ext/pcre/php_pcre.c
parent543684e7962073dcae3ecdd9504211876e630bec (diff)
downloadphp-git-83a77015ad0dcd25d30342a08cbc8ec3de077305.tar.gz
Add helper APIs for maybe-interned string creation
Add ZVAL_CHAR/RETVAL_CHAR/RETURN_CHAR as a shortcut for using ZVAL_INTERNED_STRING and ZSTR_CHAR. Add zend_string_init_fast() as a helper for the empty string / one char interned string / zend_string_init() pattern. Also add corresponding ZVAL_STRINGL_FAST etc macros. Closes GH-5684.
Diffstat (limited to 'ext/pcre/php_pcre.c')
-rw-r--r--ext/pcre/php_pcre.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 55f9d2db7b..2ed5d9d7dd 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -966,13 +966,7 @@ static void init_unmatched_empty_pair() {
static zend_always_inline void populate_match_value_str(
zval *val, const char *subject, PCRE2_SIZE start_offset, PCRE2_SIZE end_offset) {
- if (start_offset == end_offset) {
- ZVAL_EMPTY_STRING(val);
- } else if (start_offset + 1 == end_offset) {
- ZVAL_INTERNED_STR(val, ZSTR_CHAR((unsigned char) subject[start_offset]));
- } else {
- ZVAL_STRINGL(val, subject + start_offset, end_offset - start_offset);
- }
+ ZVAL_STRINGL_FAST(val, subject + start_offset, end_offset - start_offset);
}
static inline void populate_match_value(