Req #76150 [NEW]: Don't trigger copy-on-write when assigning same value

From: Date: Mon, 26 Mar 2018 07:44:43 +0000
Subject: Req #76150 [NEW]: Don't trigger copy-on-write when assigning same value
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214479@lists.php.net to get a copy of this message
From: nicolas dot grekas+php at gmail dot com Operating system: PHP version: master-Git-2018-03-26 (Git) Package: Scripting Engine problem Bug Type: Feature/Change Request Bug description:Don't trigger copy-on-write when assigning same value Description: ------------ When the key of an array is assigned an exact same value, copy-on-write is triggered, while this could be avoided. By "exact same", I mean "exact same memory address" - not "===" (which could require an array traversal to run the comparison). Here is an example in Symfony where this logic is implemented in userland (but has to use === because there is no other way to do so in userland), and where it makes a difference when measuring the memory usage: https://github.com/symfony/symfony/blob/4a602ca6529090197e09555796b27500111aee31/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php#L60-L62 Test script: --------------- $a = $someExistingArray; foreach ($a as $k => $v) { // [...] conditionnaly process $v, let's say it were unaffected; // then reassigning triggers COW, even if $v points to the exact same memory address/object $a[$k] = $v; } Expected result: ---------------- no COW -- Edit bug report at https://bugs.php.net/bug.php?id=76150&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76150&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76150&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76150&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=76150&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=76150&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=76150&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=76150&r=needscript Try newer version: https://bugs.php.net/fix.php?id=76150&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=76150&r=support Expected behavior: https://bugs.php.net/fix.php?id=76150&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=76150&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=76150&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=76150&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76150&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=76150&r=dst IIS Stability: https://bugs.php.net/fix.php?id=76150&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=76150&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=76150&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=76150&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=76150&r=mysqlcfg

« previous php.bugs (#214479) next »