From 4bd3a9006e3ce98f1cf89639bb0c6af12b5f0427 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+ndossche@users.noreply.github.com> Date: Sun, 2 Nov 2025 15:05:44 +0100 Subject: [PATCH 1/2] Use release_ex consistently in php_strtr_array_ex() (#20359) Reduces code size from 2056 -> 2006 on x86-64 with GCC 15.2.1. --- ext/standard/string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/standard/string.c b/ext/standard/string.c index c96b79f349a3..386b3ec0f1f1 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2972,7 +2972,7 @@ static void php_strtr_array_ex(zval *return_value, zend_string *input, HashTable len = ZSTR_LEN(key_used); if (UNEXPECTED(len > slen)) { /* skip long patterns */ - zend_string_release(key_used); + zend_string_release_ex(key_used, false); continue; } if (len > maxlen) { From 9300a5076d6f8e7bd5eef627d2ad35323211595d Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+ndossche@users.noreply.github.com> Date: Sun, 2 Nov 2025 15:07:15 +0100 Subject: [PATCH 2/2] Reduce code size of strripos() (#20358) Reduction of 1325 -> 1213 on x86-64 with GCC 15.2.1. --- ext/standard/string.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ext/standard/string.c b/ext/standard/string.c index 386b3ec0f1f1..6fb39c5a6bd2 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2109,13 +2109,11 @@ PHP_FUNCTION(strripos) needle_dup = zend_string_tolower(needle); if ((found = (char *)zend_memnrstr(p, ZSTR_VAL(needle_dup), ZSTR_LEN(needle_dup), e))) { RETVAL_LONG(found - ZSTR_VAL(haystack_dup)); - zend_string_release_ex(needle_dup, 0); - zend_string_release_ex(haystack_dup, 0); } else { - zend_string_release_ex(needle_dup, 0); - zend_string_release_ex(haystack_dup, 0); - RETURN_FALSE; + RETVAL_FALSE; } + zend_string_release_ex(needle_dup, false); + zend_string_release_ex(haystack_dup, false); } /* }}} */