From 6f147eb8fef758afd54a4bcc4c94da74b5b967d9 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Mon, 9 Jun 2025 18:14:37 +0200 Subject: [PATCH] Use zval_try_get_string_func() in concat_function() This allows a cheaper exception check and also does not need a release call. This shrinks concat_function() on x86-64 with GCC 15.1.1 from 3443 bytes to 3332 bytes. --- Zend/zend_operators.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 140734d1b9602..7e456ff68246a 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -1989,9 +1989,8 @@ ZEND_API zend_result ZEND_FASTCALL concat_function(zval *result, zval *op1, zval } } ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_CONCAT); - op1_string = zval_get_string_func(op1); - if (UNEXPECTED(EG(exception))) { - zend_string_release(op1_string); + op1_string = zval_try_get_string_func(op1); + if (UNEXPECTED(!op1_string)) { if (orig_op1 != result) { ZVAL_UNDEF(result); } @@ -2023,10 +2022,9 @@ ZEND_API zend_result ZEND_FASTCALL concat_function(zval *result, zval *op1, zval free_op1_string = true; } ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_CONCAT); - op2_string = zval_get_string_func(op2); - if (UNEXPECTED(EG(exception))) { + op2_string = zval_try_get_string_func(op2); + if (UNEXPECTED(!op2_string)) { zend_string_release(op1_string); - zend_string_release(op2_string); if (orig_op1 != result) { ZVAL_UNDEF(result); }