[php-src] PR #19640: Optimize array_combine with a fast path and fix memory leak

From: Date: Sat, 30 Aug 2025 19:13:21 +0000
Subject: [php-src] PR #19640: Optimize array_combine with a fast path and fix memory leak
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-32976@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/19640 Author: ENM1989 This commit introduces a "fast path" optimization for the array_combine() function to improve performance for the common case where both input arrays are packed (simple, 0-indexed lists without holes). Instead of using generic iterators, the fast path uses a direct for loop to access array elements, significantly reducing overhead. Additionally, a memory leak in the original implementation was identified and fixed. The generic code path was incorrectly incrementing the reference count of values in the newly created array, which also caused a performance degradation due to memory management overhead. This has been corrected in the fallback path. Benchmark results show a significant performance improvement: - Packed indexed arrays are ~70% faster due to the new fast path. - Associative arrays are ~65% faster due to the memory leak fix.

« previous php.git-pulls (#32976) next »