On Fri, 2013-09-20 at 17:01 +0200, ruben wrote: > >> I found out some cases where I think that some Variable Containers > >> copies could be skipped, thus saving memory and improving performance > >> relying in the copy-on-write principle. I wrote a PDF trying to explain > >> what I mean. It is not written in a very techy language, because I am > >> just new and don't know too much about the internals, but I hope you can > >> understand it and post your comments.
> Sorry, here it is: > https://www.dropbox.com/s/wxdc99miw82zje9/PHP_references.pdf Yes, in this simplified version there might be a way to figure this out by doing special handling in the return handler (basically putting the returned variable aside, do the cleanup and then see whether the separation is still needed. In most reference cases you will have other immediate calls and operations in between which change the picture. The general suggestion is: Don't use references, then the copy-on-write can work in the most efficient way and really copy only when needed. I've collected some thoughts about that on http://schlueters.de/blog/archives/125-Do-not-use-PHP-references.html Getting code with references right is hard and in 99% of the cases (exceptions are in the area of circular graphs or algorithms working on graphs ...while even there often using objects is better) other approaches lead to faster and more maintainable code. johannes -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php