<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="https://www.symmetricaldesigns.com"  xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>Symmetrical Designs - vld</title>
 <link>https://www.symmetricaldesigns.com/blog-tags/vld</link>
 <description></description>
 <language>en</language>
<item>
 <title>PHP: Pre-increment vs Post-increment</title>
 <link>https://www.symmetricaldesigns.com/blog/php-pre-increment-vs-post-increment</link>
 <description>&lt;div class=&quot;field field-name-body field-type-text-with-summary field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;p&gt;If the idea is to increment a variable and not care about the intermediate value, then pre-increment might be faster than post-increment. Here is why:&lt;/p&gt;
&lt;p&gt;e-g incrementing an object variable&lt;/p&gt;
&lt;p&gt;$o-&amp;gt;aa++ vs ++$o-&amp;gt;aa&lt;/p&gt;
&lt;p&gt;The opcodes for post-increment:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;   3        POST_INC_OBJ                                     ~1      !0, &#039;aa&#039;&lt;br /&gt;   4        FREE                                                     ~1&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;has to save the incoming value (for later return) and do the actual increment. The returned value has to be &quot;freed&quot; even though it is not being used. Optimizers might look at these patterns and change them to pre-increment. If optimizers are not used, then this will end up wasting extra cycles.&lt;/p&gt;
&lt;p&gt;The opcodes for pre-increment:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;   3        PRE_INC_OBJ                                              !0, &#039;aa&#039;&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;Nothing is returned and hence does not have to be freed.&lt;/p&gt;
&lt;p&gt;e-g increment a variable&lt;/p&gt;
&lt;p&gt;$i++ vs ++$i&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;   8        POST_INC                                         ~3      !1&lt;br /&gt;   9        FREE                                                     ~3&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;   11       PRE_INC                                                  !1&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;The PHP opcodes can be easily dumped using tools like &lt;a href=&quot;http://derickrethans.nl/projects.html#vld&quot;&gt;vld&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-blog-category field-type-taxonomy-term-reference field-label-hidden clearfix&quot;&gt;&lt;ul class=&quot;links&quot;&gt;&lt;li class=&quot;taxonomy-term-reference-0&quot;&gt;&lt;a href=&quot;/blog-categories/php&quot;&gt;PHP&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-blog-tags field-type-taxonomy-term-reference field-label-above clearfix&quot;&gt;&lt;h3 class=&quot;field-label&quot;&gt;Tags: &lt;/h3&gt;&lt;ul class=&quot;links&quot;&gt;&lt;li class=&quot;taxonomy-term-reference-0&quot;&gt;&lt;a href=&quot;/blog-tags/opcode&quot;&gt;opcode&lt;/a&gt;&lt;/li&gt;&lt;li class=&quot;taxonomy-term-reference-1&quot;&gt;&lt;a href=&quot;/blog-tags/performance&quot;&gt;performance&lt;/a&gt;&lt;/li&gt;&lt;li class=&quot;taxonomy-term-reference-2&quot;&gt;&lt;a href=&quot;/blog-tags/vld&quot;&gt;vld&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div class=&quot;field field-name-field-blog-addthis field-type-addthis field-label-hidden&quot;&gt;&lt;div class=&quot;field-items&quot;&gt;&lt;div class=&quot;field-item even&quot;&gt;&lt;div class=&quot;addthis_toolbox addthis_default_style  &quot; addthis:title=&quot;PHP: Pre-increment vs Post-increment - Symmetrical Designs&quot; addthis:url=&quot;https://www.symmetricaldesigns.com/blog/php-pre-increment-vs-post-increment&quot;&gt;&lt;a href=&quot;http://www.addthis.com/bookmark.php?v=250&quot; class=&quot;addthis_button_facebook&quot;&gt;&lt;/a&gt;
&lt;a href=&quot;http://www.addthis.com/bookmark.php?v=250&quot; class=&quot;addthis_button_twitter&quot;&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Thu, 11 Feb 2016 00:54:45 +0000</pubDate>
 <dc:creator>mani</dc:creator>
 <guid isPermaLink="false">134 at https://www.symmetricaldesigns.com</guid>
</item>
</channel>
</rss>
