Skip to content

Commit 28a083b

Browse files
authored
Use zend_string_release_ex() in concat_function() (#18827)
The strings we encounter are either interned in which case the persistent bool doesn't matter; or they're temporary as the code already assumes that anyway. This patch shrinks the function from 3332 bytes to 3173 bytes on x86-64 with GCC 15.1.1.
1 parent 029a788 commit 28a083b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Zend/zend_operators.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,7 +2024,7 @@ ZEND_API zend_result ZEND_FASTCALL concat_function(zval *result, zval *op1, zval
20242024
ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_CONCAT);
20252025
op2_string = zval_try_get_string_func(op2);
20262026
if (UNEXPECTED(!op2_string)) {
2027-
zend_string_release(op1_string);
2027+
zend_string_release_ex(op1_string, false);
20282028
if (orig_op1 != result) {
20292029
ZVAL_UNDEF(result);
20302030
}
@@ -2069,8 +2069,8 @@ has_op2_string:;
20692069
uint32_t flags = ZSTR_GET_COPYABLE_CONCAT_PROPERTIES_BOTH(op1_string, op2_string);
20702070

20712071
if (UNEXPECTED(op1_len > ZSTR_MAX_LEN - op2_len)) {
2072-
if (free_op1_string) zend_string_release(op1_string);
2073-
if (free_op2_string) zend_string_release(op2_string);
2072+
if (free_op1_string) zend_string_release_ex(op1_string, false);
2073+
if (free_op2_string) zend_string_release_ex(op2_string, false);
20742074
zend_throw_error(NULL, "String size overflow");
20752075
if (orig_op1 != result) {
20762076
ZVAL_UNDEF(result);
@@ -2093,7 +2093,7 @@ has_op2_string:;
20932093
/* account for the case where result_str == op1_string == op2_string and the realloc is done */
20942094
if (op1_string == op2_string) {
20952095
if (free_op2_string) {
2096-
zend_string_release(op2_string);
2096+
zend_string_release_ex(op2_string, false);
20972097
free_op2_string = false;
20982098
}
20992099
op2_string = result_str;
@@ -2112,8 +2112,8 @@ has_op2_string:;
21122112
ZSTR_VAL(result_str)[result_len] = '\0';
21132113
}
21142114

2115-
if (free_op1_string) zend_string_release(op1_string);
2116-
if (free_op2_string) zend_string_release(op2_string);
2115+
if (free_op1_string) zend_string_release_ex(op1_string, false);
2116+
if (free_op2_string) zend_string_release_ex(op2_string, false);
21172117

21182118
return SUCCESS;
21192119
}

0 commit comments

Comments
 (0)