From 309e66d98473ff991b259d5c1ea5b13a0ee4b921 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Fri, 3 Jan 2025 12:28:14 +0100 Subject: [PATCH] Use zend_new_pair() for hrtime() (#17328) This is a specialised optimized helper to return a pair. --- ext/standard/hrtime.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/standard/hrtime.c b/ext/standard/hrtime.c index 6af8bfc9650..f8d5e317913 100644 --- a/ext/standard/hrtime.c +++ b/ext/standard/hrtime.c @@ -58,10 +58,10 @@ PHP_FUNCTION(hrtime) if (UNEXPECTED(get_as_num)) { PHP_RETURN_HRTIME(t); } else { - array_init_size(return_value, 2); - zend_hash_real_init_packed(Z_ARRVAL_P(return_value)); - add_next_index_long(return_value, (zend_long)(t / (zend_hrtime_t)ZEND_NANO_IN_SEC)); - add_next_index_long(return_value, (zend_long)(t % (zend_hrtime_t)ZEND_NANO_IN_SEC)); + zval first, second; + ZVAL_LONG(&first, (zend_long)(t / (zend_hrtime_t)ZEND_NANO_IN_SEC)); + ZVAL_LONG(&second, (zend_long)(t % (zend_hrtime_t)ZEND_NANO_IN_SEC)); + RETURN_ARR(zend_new_pair(&first, &second)); } #else RETURN_FALSE;