<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Developer Day &#187; lazy-copy</title>
	<atom:link href="http://www.thedeveloperday.com/tag/lazy-copy/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thedeveloperday.com</link>
	<description>Staying Curious</description>
	<lastBuildDate>Fri, 03 Feb 2012 12:03:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PHP lazy copy or copy on write</title>
		<link>http://www.thedeveloperday.com/php-lazy-copy/</link>
		<comments>http://www.thedeveloperday.com/php-lazy-copy/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 21:59:14 +0000</pubDate>
		<dc:creator>Žilvinas Šaltys</dc:creator>
				<category><![CDATA[Optimization]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[copy-on-write]]></category>
		<category><![CDATA[lazy-copy]]></category>

		<guid isPermaLink="false">http://www.thedeveloperday.com/php-lazy-copy/</guid>
		<description><![CDATA[Here&#8217;s an interesting question from the Zend exam practice test: &#8220;Absent any actual need for choosing one method over the other, does passing arrays by value to a read-only function reduce performance compared to passing them by reference?&#8217; I wondered well PHP would have to make a copy of the variable passed so that would [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an interesting question from the Zend exam practice test:</p>
<blockquote><p>&#8220;Absent any actual need for choosing one method over the other, does passing arrays by value to a read-only function reduce performance compared to passing them by reference?&#8217;</p></blockquote>
<p>I wondered well PHP would have to make a copy of the variable passed so that would be slower than passing it by reference. I was wrong. Turns out PHP uses a lazy-copy mechanism (also called copy-on-write) that does not actually create a copy of a variable until it is modified. And since PHP must create a set of structures that it uses to maintain the reference it is actually &#8220;slower&#8221; to pass a variable to a read-only function by reference.</p>
<p>Having programmed for quite a few years I could have thought of that myself. Strangely this was not in the study guide.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thedeveloperday.com/php-lazy-copy/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

