From 83a77015ad0dcd25d30342a08cbc8ec3de077305 Mon Sep 17 00:00:00 2001 From: twosee Date: Mon, 8 Jun 2020 18:45:01 +0800 Subject: 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. --- ext/pcre/php_pcre.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'ext/pcre/php_pcre.c') 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( -- cgit v1.2.1