[php-src] Issue #11775: Foreach argument CoW should be optimized

From: Date: Sun, 23 Jul 2023 11:25:33 +0000
Subject: [php-src] Issue #11775: Foreach argument CoW should be optimized
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-245018@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11775 Author: mvorisek ### Description Currently, foreach does CoW on any foreach argument ($arr) modification. This is too conservative. https://3v4l.org/ShQmT/rfc#vgit.master The repro shows common usecase of modifying currently iterated item/index. CoW is not needed, as the currently iterated item/index will never be iterated again. In general, any already iterated item/key does not need CoW when unset/modified. Also $arr append does not need CoW neither as the last element of the original $arr can be easily tracked.

« previous php.bugs (#245018) next »