<?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>JActionScripters &#187; Tips</title>
	<atom:link href="http://blog.jactionscripters.com/tag/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jactionscripters.com</link>
	<description>More than 20 Japanese flash coders share the blog/ You will be junkie for this crazy Japanese Flash news</description>
	<lastBuildDate>Sun, 20 Jun 2010 10:03:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Optimize iteration for Particle</title>
		<link>http://blog.jactionscripters.com/2009/05/22/optimize-iteration-for-particle/</link>
		<comments>http://blog.jactionscripters.com/2009/05/22/optimize-iteration-for-particle/#comments</comments>
		<pubDate>Fri, 22 May 2009 05:08:45 +0000</pubDate>
		<dc:creator>Yoshihiro Shindo</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Experiment]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=598</guid>
		<description><![CDATA[Few weeks ago, Particle was a trend in Japanese Flash guys. Many works were posted to the Wonderfl with a tag &#8220;パーティクル祭 (Particle Matsuri)&#8221; (means Particle Festival).
In one of them, there is &#8220;100,000 particles&#8221; posted by bkzen. I think it&#8217;s pretty cool! but I need more speed. :p So I posted a quick optmized one. [...]]]></description>
			<content:encoded><![CDATA[<p>Few weeks ago, <a href="http://en.wikipedia.org/wiki/Particle_system">Particle</a> was a trend in Japanese Flash guys. Many works <a href="http://wonderfl.kayac.com/tag/%E3%83%91%E3%83%BC%E3%83%86%E3%82%A3%E3%82%AF%E3%83%AB%E7%A5%AD">were posted to the Wonderfl with a tag &#8220;パーティクル祭 (Particle Matsuri)&#8221;</a> (means Particle Festival).</p>
<p>In one of them, there is <a href="http://wonderfl.kayac.com/code/b218434cf7db99283847f9947b221628ac408346">&#8220;100,000 particles&#8221;</a> posted by <a href="http://blog.bk-zen.com/">bkzen</a>. I think it&#8217;s pretty cool! but I need more speed. :p So I posted a <a href="http://wonderfl.kayac.com/code/6efe4c0d9b5e27e91db92b1175409f31e7005dca">quick optmized one</a>. It brings 33% faster (21fps -> 28fps) in my Mac. <img src='http://blog.jactionscripters.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>You can see what did I changed by clicking &#8220;diff&#8221; link in above page. In short, I changed an iteration method from Array to <a href="http://en.wikipedia.org/wiki/Linked_list">LinkedList</a>. Because array index access and calculating and checking an index (variable i) are pretty slow.</p>
<p><code-style>
<pre name="code" class="as3">
// Slow
while (i > num) {
    p = particles[i];
    // do something
    i++;
}
</pre>
<p></code-style></p>
<p>But accessing an member variable is fast because it's optimized by AVM2. So it causes fast iteration.</p>
<p><code-style>
<pre name="code" class="as3">
// Fast
while ((p = p.next) != null) {
    // do something
}
</pre>
<p></code-style></p>
<p>Please use this optimization if you need fast iteration especially in case you have a large data.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2009/05/22/optimize-iteration-for-particle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
