Commit 1849f03afc7 for php.net
commit 1849f03afc7d1c87d9f25000e8fa5f33b3f35faf
Author: Weilin Du <weilindu@php.net>
Date: Tue Sep 15 15:47:32 2026 +0800
ext/standard: Optimize integer key insertion in array_change_key_case()
Integer keys are copied unchanged from the input and remain unique in the
new result. Use zend_hash_index_add_new() to avoid redundant checks.
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 213402c7819..0df44f8242b 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -4896,7 +4896,7 @@ PHP_FUNCTION(array_change_key_case)
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_key, string_key, entry) {
if (!string_key) {
- entry = zend_hash_index_update(Z_ARRVAL_P(return_value), num_key, entry);
+ entry = zend_hash_index_add_new(Z_ARRVAL_P(return_value), num_key, entry);
} else {
if (change_to_upper == PHP_CASE_UPPER) {
new_key = zend_string_toupper(string_key);