From c24aa4c7aa5e84790d03544d238cb0a34adba285 Mon Sep 17 00:00:00 2001 From: ndossche <7771979+ndossche@users.noreply.github.com> Date: Tue, 15 Sep 2026 20:59:50 +0200 Subject: [PATCH] Zend: use ZVAL_COPY_DEREF when possible Cleaner, but also an optimized macro. --- Zend/zend_exceptions.c | 9 +++------ Zend/zend_execute.c | 3 +-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 062ba0f3b188..9702a335d461 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -462,8 +462,7 @@ ZEND_METHOD(Exception, getCode) ZEND_PARSE_PARAMETERS_NONE(); prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_CODE); - ZVAL_DEREF(prop); - ZVAL_COPY(return_value, prop); + ZVAL_COPY_DEREF(return_value, prop); } /* }}} */ @@ -475,8 +474,7 @@ ZEND_METHOD(Exception, getTrace) ZEND_PARSE_PARAMETERS_NONE(); prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_TRACE); - ZVAL_DEREF(prop); - ZVAL_COPY(return_value, prop); + ZVAL_COPY_DEREF(return_value, prop); } /* }}} */ @@ -488,8 +486,7 @@ ZEND_METHOD(ErrorException, getSeverity) ZEND_PARSE_PARAMETERS_NONE(); prop = GET_PROPERTY(ZEND_THIS, ZEND_STR_SEVERITY); - ZVAL_DEREF(prop); - ZVAL_COPY(return_value, prop); + ZVAL_COPY_DEREF(return_value, prop); } /* }}} */ diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 14a340ffee37..9047550cafb0 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1080,8 +1080,7 @@ static zend_never_inline zval* zend_assign_to_typed_prop(const zend_property_inf } } - ZVAL_DEREF(value); - ZVAL_COPY(&tmp, value); + ZVAL_COPY_DEREF(&tmp, value); if (UNEXPECTED(!i_zend_verify_property_type(info, &tmp, EX_USES_STRICT_TYPES()))) { zval_ptr_dtor(&tmp);