Doc #54870 [Fbk->Csd]: References Comment Should be Removed

From: Date: Sat, 02 Jul 2011 22:41:45 +0000
Subject: Doc #54870 [Fbk->Csd]: References Comment Should be Removed
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-6818@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=54870&edit=1 ID: 54870 Updated by: frozenfire@php.net Reported by: miqrogroove at gmail dot com Summary: References Comment Should be Removed -Status: Feedback +Status: Closed Type: Documentation Problem Package: Documentation problem PHP Version: Irrelevant Assigned To: frozenfire Block user comment: N Private report: N New Comment: I asked a few people for comments regarding this, and the prevailing opinion matches my previous comment. While I applaud your investigation of the nuances of the copy-on-write functionality, I'll be marking this bug closed, unless someone disagrees. Previous Comments: ------------------------------------------------------------------------ [2011-07-02 18:26:52] frozenfire@php.net While I recognize that using references in the way that you suggest could provide some performance increase, I think that for the most purposes, it's not worth the complexity increase to do so. Doing this is a sort of premature optimization, so it's something that most users of PHP should avoid. As such, I'm inclined to keep the quoted text, because it is *pragmatically correct*, even if it's technically incorrect on some level. ------------------------------------------------------------------------ [2011-05-20 07:42:52] miqrogroove at gmail dot com Description: ------------ I've done some testing of variable reference behavior in PHP and was able to disprove something in the documentation. On the manual page at http://php.net/manual/en/functions.arguments.php there is a comment that says, "Note that passing by reference doesn't speed up your php script. PHP is smart enough not to simply copy data every time the language requires it. Rahter, PHP uses a reference and waits until the copy (a copied variable or a copy used in a function) is actually used as a copy and creates one then." That statement is not correct in any circumstance I could come up with, except for a read-only function accepting a one megabyte string argument. I observed massive performance improvements when using references to prevent the copy-on- write behavior. So, to say that passing by reference doesn't speed up your php script is not correct. It is only correct to say that if a parameter is passed by value and never modified, then PHP wont make an extra copy of it. Test script: --------------- Details posted at http://www.miqrogroove.com/writing/php-references-for-speed/ ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=54870&edit=1

« previous php.doc.bugs (#6818) next »