Skip to content

Commit 309e66d

Browse files
authored
Use zend_new_pair() for hrtime() (#17328)
This is a specialised optimized helper to return a pair.
1 parent 60252b7 commit 309e66d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ext/standard/hrtime.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ PHP_FUNCTION(hrtime)
5858
if (UNEXPECTED(get_as_num)) {
5959
PHP_RETURN_HRTIME(t);
6060
} else {
61-
array_init_size(return_value, 2);
62-
zend_hash_real_init_packed(Z_ARRVAL_P(return_value));
63-
add_next_index_long(return_value, (zend_long)(t / (zend_hrtime_t)ZEND_NANO_IN_SEC));
64-
add_next_index_long(return_value, (zend_long)(t % (zend_hrtime_t)ZEND_NANO_IN_SEC));
61+
zval first, second;
62+
ZVAL_LONG(&first, (zend_long)(t / (zend_hrtime_t)ZEND_NANO_IN_SEC));
63+
ZVAL_LONG(&second, (zend_long)(t % (zend_hrtime_t)ZEND_NANO_IN_SEC));
64+
RETURN_ARR(zend_new_pair(&first, &second));
6565
}
6666
#else
6767
RETURN_FALSE;

0 commit comments

Comments
 (0)