<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Tips on how to write efficient AS3 &#8211; part 2</title>
	<atom:link href="http://www.lostinactionscript.com/blog/index.php/2008/11/01/tips-on-how-to-write-efficient-as3-part-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lostinactionscript.com/blog/index.php/2008/11/01/tips-on-how-to-write-efficient-as3-part-2/</link>
	<description>Lost In Actionscript</description>
	<lastBuildDate>Wed, 08 Sep 2010 12:01:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Francky&#39;s FlashBlog &#187; AS3 Code Optimisation</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2008/11/01/tips-on-how-to-write-efficient-as3-part-2/comment-page-1/#comment-2709</link>
		<dc:creator>Francky&#39;s FlashBlog &#187; AS3 Code Optimisation</dc:creator>
		<pubDate>Sun, 08 Aug 2010 03:11:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=81#comment-2709</guid>
		<description>[...] Tips on how to write efficient AS3 – part 2 [...]</description>
		<content:encoded><![CDATA[<p>[...] Tips on how to write efficient AS3 – part 2 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shane McCartney</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2008/11/01/tips-on-how-to-write-efficient-as3-part-2/comment-page-1/#comment-2673</link>
		<dc:creator>Shane McCartney</dc:creator>
		<pubDate>Mon, 10 May 2010 06:56:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=81#comment-2673</guid>
		<description>That&#039;s good information although my examples were on Array as I don&#039;t think I did any fp10 tests back then.</description>
		<content:encoded><![CDATA[<p>That&#8217;s good information although my examples were on Array as I don&#8217;t think I did any fp10 tests back then.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DieTapete</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2008/11/01/tips-on-how-to-write-efficient-as3-part-2/comment-page-1/#comment-2672</link>
		<dc:creator>DieTapete</dc:creator>
		<pubDate>Sat, 08 May 2010 13:24:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=81#comment-2672</guid>
		<description>Here are my results for &quot;Vector push vs. Vector index&quot;:
(average of 5 runs)
Player 10.0 r22
   push: 1331 
   length: 1401
Player 10.1 r52
   push: 1184
   length: 769

So, I think you can take nothing for granted. It always depends on the player..</description>
		<content:encoded><![CDATA[<p>Here are my results for &#8220;Vector push vs. Vector index&#8221;:<br />
(average of 5 runs)<br />
Player 10.0 r22<br />
   push: 1331<br />
   length: 1401<br />
Player 10.1 r52<br />
   push: 1184<br />
   length: 769</p>
<p>So, I think you can take nothing for granted. It always depends on the player..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2008/11/01/tips-on-how-to-write-efficient-as3-part-2/comment-page-1/#comment-2662</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Thu, 08 Apr 2010 06:03:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=81#comment-2662</guid>
		<description>Check out this nice flex as3 performance tester: 
http://businessintelligence.me/projects/performance_tester/performanceTester.html</description>
		<content:encoded><![CDATA[<p>Check out this nice flex as3 performance tester:<br />
<a href="http://businessintelligence.me/projects/performance_tester/performanceTester.html" rel="nofollow">http://businessintelligence.me/projects/performance_tester/performanceTester.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Flash on the Beach 2009 - Day 2 &#124; Flash Monkey</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2008/11/01/tips-on-how-to-write-efficient-as3-part-2/comment-page-1/#comment-2070</link>
		<dc:creator>Flash on the Beach 2009 - Day 2 &#124; Flash Monkey</dc:creator>
		<pubDate>Thu, 24 Sep 2009 17:16:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=81#comment-2070</guid>
		<description>[...] as his talk was all about how to optimise code and save on CPU usage. Earlier in the year I read Shane McCartney’s great posts on the same subject and Grant’s presentation followed on from them to an extent. I don’t want [...]</description>
		<content:encoded><![CDATA[<p>[...] as his talk was all about how to optimise code and save on CPU usage. Earlier in the year I read Shane McCartney’s great posts on the same subject and Grant’s presentation followed on from them to an extent. I don’t want [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shane McCartney</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2008/11/01/tips-on-how-to-write-efficient-as3-part-2/comment-page-1/#comment-2037</link>
		<dc:creator>Shane McCartney</dc:creator>
		<pubDate>Fri, 21 Aug 2009 08:02:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=81#comment-2037</guid>
		<description>Yup that is definitely correct and was mentioned in my presentation re: variable length also results differ depending on wether debugging is used or not too. Forcing the this keyword makes sense I will have to test that out. I habitually use the this keyword because of FDT and Flex Builder autocomplete but never really considering the performance advantage to it.</description>
		<content:encoded><![CDATA[<p>Yup that is definitely correct and was mentioned in my presentation re: variable length also results differ depending on wether debugging is used or not too. Forcing the this keyword makes sense I will have to test that out. I habitually use the this keyword because of FDT and Flex Builder autocomplete but never really considering the performance advantage to it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Bunte</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2008/11/01/tips-on-how-to-write-efficient-as3-part-2/comment-page-1/#comment-2035</link>
		<dc:creator>Daniel Bunte</dc:creator>
		<pubDate>Tue, 18 Aug 2009 12:42:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=81#comment-2035</guid>
		<description>Hi,
I have some additions and notes to your entries:

Long vs Short variable names
This only applies to class-variables and parameter-variables as in
package
{
  public class foo
  {
     private var bar:String;

     private function fooBar(myLongVariableNameWillGetIntoHashTable:int = -1):void {}
  }
}

All variables used inside methods are irrelevant, because these are transformed by the compiler, so they are not in a hash-table.


Multiplication vs. Division
Also notice that if dividing by 2, 4, 8, 16, etc. it is slight faster using bit-shift operators:
sprite.width = parent.width / 2;
would be:
sprite.width = parent.width &gt;&gt; 1;


Var declarations on multiple lines vs. Var declarations on a single line
I figured out that declaring multiple vars in a single line is faster when using the keyword var before every variable:
var i:int, j:int, k:int; //slower than
var i:int; var j:int; var k:int;

The problem is that it&#039;s hard to read such code. I&#039;m currently working on a Obfuscator that will also do some code-improvements.
I like the version of writing
var[TAB]i:int,
[TAB]j:int,
[TAB]k:int;
So you have all variables well-formatted :)


And one last additional hint:
When using class-variable, it&#039;s faster accessible by using the this-keyword:
private var foo:String = &#039;hello world&#039;;

function bar():void
{
  trace(foo); //is very slow
  trace(this.foo); //is much faster
}

This is because the JIT has too look where the declared variable exists. If using this, the JIT knows that foo is a class-variable, otherwise it could also be a method-variable.


Kind Regards,
 Daniel Bunte</description>
		<content:encoded><![CDATA[<p>Hi,<br />
I have some additions and notes to your entries:</p>
<p>Long vs Short variable names<br />
This only applies to class-variables and parameter-variables as in<br />
package<br />
{<br />
  public class foo<br />
  {<br />
     private var bar:String;</p>
<p>     private function fooBar(myLongVariableNameWillGetIntoHashTable:int = -1):void {}<br />
  }<br />
}</p>
<p>All variables used inside methods are irrelevant, because these are transformed by the compiler, so they are not in a hash-table.</p>
<p>Multiplication vs. Division<br />
Also notice that if dividing by 2, 4, 8, 16, etc. it is slight faster using bit-shift operators:<br />
sprite.width = parent.width / 2;<br />
would be:<br />
sprite.width = parent.width &gt;&gt; 1;</p>
<p>Var declarations on multiple lines vs. Var declarations on a single line<br />
I figured out that declaring multiple vars in a single line is faster when using the keyword var before every variable:<br />
var i:int, j:int, k:int; //slower than<br />
var i:int; var j:int; var k:int;</p>
<p>The problem is that it&#8217;s hard to read such code. I&#8217;m currently working on a Obfuscator that will also do some code-improvements.<br />
I like the version of writing<br />
var[TAB]i:int,<br />
[TAB]j:int,<br />
[TAB]k:int;<br />
So you have all variables well-formatted :)</p>
<p>And one last additional hint:<br />
When using class-variable, it&#8217;s faster accessible by using the this-keyword:<br />
private var foo:String = &#8216;hello world&#8217;;</p>
<p>function bar():void<br />
{<br />
  trace(foo); //is very slow<br />
  trace(this.foo); //is much faster<br />
}</p>
<p>This is because the JIT has too look where the declared variable exists. If using this, the JIT knows that foo is a class-variable, otherwise it could also be a method-variable.</p>
<p>Kind Regards,<br />
 Daniel Bunte</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shane McCartney</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2008/11/01/tips-on-how-to-write-efficient-as3-part-2/comment-page-1/#comment-1716</link>
		<dc:creator>Shane McCartney</dc:creator>
		<pubDate>Tue, 05 May 2009 22:54:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=81#comment-1716</guid>
		<description>This tip also applies to the Vector type.</description>
		<content:encoded><![CDATA[<p>This tip also applies to the Vector type.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aadil</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2008/11/01/tips-on-how-to-write-efficient-as3-part-2/comment-page-1/#comment-1712</link>
		<dc:creator>Aadil</dc:creator>
		<pubDate>Tue, 05 May 2009 19:48:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=81#comment-1712</guid>
		<description>Hi

I&#039;m curious to know if the first point on Array.push () and Array.length is applicable to the new Vector. data type in Flex 3.3 and FP10?</description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>I&#8217;m curious to know if the first point on Array.push () and Array.length is applicable to the new Vector. data type in Flex 3.3 and FP10?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Read the script at Abandon by Road</title>
		<link>http://www.lostinactionscript.com/blog/index.php/2008/11/01/tips-on-how-to-write-efficient-as3-part-2/comment-page-1/#comment-1309</link>
		<dc:creator>Read the script at Abandon by Road</dc:creator>
		<pubDate>Fri, 27 Mar 2009 08:36:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.lostinactionscript.com/blog/?p=81#comment-1309</guid>
		<description>[...] http://www.lostinactionscript.com/blog/index.php/2008/11/01/tips-on-how-to-write-efficient-as3-part-...      &#171; Cancer Fry [...]</description>
		<content:encoded><![CDATA[<p>[...] <a href="http://www.lostinactionscript.com/blog/index.php/2008/11/01/tips-on-how-to-write-efficient-as3-part-.." rel="nofollow">http://www.lostinactionscript.com/blog/index.php/2008/11/01/tips-on-how-to-write-efficient-as3-part-..</a>.      &laquo; Cancer Fry [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
