Commit d86182f7efa for php.net

commit d86182f7efa8066d53c4fe3c940907ff75d12133
Author: Niels Dossche <7771979+ndossche@users.noreply.github.com>
Date:   Tue Dec 23 00:37:29 2025 +0100

    date: Avoid passing objects using double pointers

    Using single pointers is cleaner and also generates better machine code.

diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 4494f79a0db..8f98589b2b4 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -4613,7 +4613,7 @@ PHP_METHOD(DateInterval, __construct)
 }
 /* }}} */

-static void php_date_interval_initialize_from_hash(php_interval_obj **intobj, const HashTable *myht) /* {{{ */
+static void php_date_interval_initialize_from_hash(php_interval_obj *intobj, const HashTable *myht) /* {{{ */
 {
 	/* If we have a date_string, use that instead */
 	const zval *date_str = zend_hash_str_find(myht, "date_string", strlen("date_string"));
@@ -4635,15 +4635,15 @@ static void php_date_interval_initialize_from_hash(php_interval_obj **intobj, co
 		}

 		/* If ->diff is already set, then we need to free it first */
-		if ((*intobj)->diff) {
-			timelib_rel_time_dtor((*intobj)->diff);
+		if (intobj->diff) {
+			timelib_rel_time_dtor(intobj->diff);
 		}

-		(*intobj)->diff = timelib_rel_time_clone(&time->relative);
-		(*intobj)->initialized = true;
-		(*intobj)->civil_or_wall = PHP_DATE_CIVIL;
-		(*intobj)->from_string = true;
-		(*intobj)->date_string = zend_string_copy(Z_STR_P(date_str));
+		intobj->diff = timelib_rel_time_clone(&time->relative);
+		intobj->initialized = true;
+		intobj->civil_or_wall = PHP_DATE_CIVIL;
+		intobj->from_string = true;
+		intobj->date_string = zend_string_copy(Z_STR_P(date_str));

 		timelib_time_dtor(time);
 		timelib_error_container_dtor(err);
@@ -4652,20 +4652,20 @@ static void php_date_interval_initialize_from_hash(php_interval_obj **intobj, co
 	}

 	/* If ->diff is already set, then we need to free it first */
-	if ((*intobj)->diff) {
-		timelib_rel_time_dtor((*intobj)->diff);
+	if (intobj->diff) {
+		timelib_rel_time_dtor(intobj->diff);
 	}

 	/* Set new value */
-	(*intobj)->diff = timelib_rel_time_ctor();
+	intobj->diff = timelib_rel_time_ctor();

 #define PHP_DATE_INTERVAL_READ_PROPERTY(element, member, itype, def) \
 	do { \
 		zval *z_arg = zend_hash_str_find(myht, element, sizeof(element) - 1); \
 		if (z_arg && Z_TYPE_P(z_arg) <= IS_STRING) { \
-			(*intobj)->diff->member = (itype)zval_get_long(z_arg); \
+			intobj->diff->member = (itype)zval_get_long(z_arg); \
 		} else { \
-			(*intobj)->diff->member = (itype)def; \
+			intobj->diff->member = (itype)def; \
 		} \
 	} while (0);

@@ -4675,10 +4675,10 @@ static void php_date_interval_initialize_from_hash(php_interval_obj **intobj, co
 		if (z_arg && Z_TYPE_P(z_arg) <= IS_STRING) { \
 			zend_string *tmp_str; \
 			zend_string *str = zval_get_tmp_string(z_arg, &tmp_str); \
-			DATE_A64I((*intobj)->diff->member, ZSTR_VAL(str)); \
+			DATE_A64I(intobj->diff->member, ZSTR_VAL(str)); \
 			zend_tmp_string_release(tmp_str); \
 		} else { \
-			(*intobj)->diff->member = -1LL; \
+			intobj->diff->member = -1LL; \
 		} \
 	} while (0);

@@ -4686,14 +4686,14 @@ static void php_date_interval_initialize_from_hash(php_interval_obj **intobj, co
 	do { \
 		zval *z_arg = zend_hash_str_find(myht, "days", sizeof("days") - 1); \
 		if (z_arg && Z_TYPE_P(z_arg) == IS_FALSE) { \
-			(*intobj)->diff->member = TIMELIB_UNSET; \
+			intobj->diff->member = TIMELIB_UNSET; \
 		} else if (z_arg && Z_TYPE_P(z_arg) <= IS_STRING) { \
 			zend_string *tmp_str; \
 			zend_string *str = zval_get_tmp_string(z_arg, &tmp_str); \
-			DATE_A64I((*intobj)->diff->member, ZSTR_VAL(str)); \
+			DATE_A64I(intobj->diff->member, ZSTR_VAL(str)); \
 			zend_tmp_string_release(tmp_str); \
 		} else { \
-			(*intobj)->diff->member = -1LL; \
+			intobj->diff->member = -1LL; \
 		} \
 	} while (0);

@@ -4701,9 +4701,9 @@ static void php_date_interval_initialize_from_hash(php_interval_obj **intobj, co
 	do { \
 		zval *z_arg = zend_hash_str_find(myht, element, sizeof(element) - 1); \
 		if (z_arg) { \
-			(*intobj)->diff->member = (double)zval_get_double(z_arg); \
+			intobj->diff->member = (double)zval_get_double(z_arg); \
 		} else { \
-			(*intobj)->diff->member = (double)def; \
+			intobj->diff->member = (double)def; \
 		} \
 	} while (0);

@@ -4716,7 +4716,7 @@ static void php_date_interval_initialize_from_hash(php_interval_obj **intobj, co
 	{
 		const zval *z_arg = zend_hash_str_find(myht, "f", sizeof("f") - 1);
 		if (z_arg) {
-			(*intobj)->diff->us = zend_dval_to_lval(zval_get_double(z_arg) * 1000000.0);
+			intobj->diff->us = zend_dval_to_lval(zval_get_double(z_arg) * 1000000.0);
 		}
 	}
 	PHP_DATE_INTERVAL_READ_PROPERTY("weekday", weekday, int, -1)
@@ -4730,14 +4730,14 @@ static void php_date_interval_initialize_from_hash(php_interval_obj **intobj, co
 	PHP_DATE_INTERVAL_READ_PROPERTY("have_special_relative", have_special_relative, unsigned int, 0);
 	{
 		const zval *z_arg = zend_hash_str_find(myht, "civil_or_wall", sizeof("civil_or_wall") - 1);
-		(*intobj)->civil_or_wall = PHP_DATE_CIVIL;
+		intobj->civil_or_wall = PHP_DATE_CIVIL;
 		if (z_arg) {
 			zend_long val = zval_get_long(z_arg);
-			(*intobj)->civil_or_wall = val;
+			intobj->civil_or_wall = val;
 		}
 	}

-	(*intobj)->initialized = true;
+	intobj->initialized = true;
 } /* }}} */

 /* {{{ */
@@ -4752,7 +4752,7 @@ PHP_METHOD(DateInterval, __set_state)

 	php_date_instantiate(date_ce_interval, return_value);
 	intobj = Z_PHPINTERVAL_P(return_value);
-	php_date_interval_initialize_from_hash(&intobj, myht);
+	php_date_interval_initialize_from_hash(intobj, myht);
 }
 /* }}} */

@@ -4823,7 +4823,7 @@ PHP_METHOD(DateInterval, __unserialize)

 	intervalobj = Z_PHPINTERVAL_P(object);

-	php_date_interval_initialize_from_hash(&intervalobj, myht);
+	php_date_interval_initialize_from_hash(intervalobj, myht);
 	restore_custom_dateinterval_properties(object, myht);
 }
 /* }}} */
@@ -4841,7 +4841,7 @@ PHP_METHOD(DateInterval, __wakeup)

 	myht = Z_OBJPROP_P(object);

-	php_date_interval_initialize_from_hash(&intobj, myht);
+	php_date_interval_initialize_from_hash(intobj, myht);
 }
 /* }}} */