<?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>blog.betabong.com &#187; parsing</title>
	<atom:link href="http://blog.betabong.com/tag/parsing/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.betabong.com</link>
	<description></description>
	<lastBuildDate>Thu, 13 May 2010 09:49:40 +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>BBML Presentation at SFUG</title>
		<link>http://blog.betabong.com/2009/04/22/bbml-presentation/</link>
		<comments>http://blog.betabong.com/2009/04/22/bbml-presentation/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 08:02:14 +0000</pubDate>
		<dc:creator>betabong</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash & more]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[bbml]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[sfug]]></category>

		<guid isPermaLink="false">http://blog.betabong.com/?p=262</guid>
		<description><![CDATA[Yesterday I had a presentation at the SFUG meeting covering some bits of my rewritten BBML framework (originated from the project laax.com). I&#8217;ve tried to share some insights into the technical concept and strategies for CSS parsing, CSS selectors and layout validation.

Picture by Marc Liyanage
It&#8217;s been surprisingly fun (I give credits to the beer sponsored [...]


Related posts:<ol><li><a href='http://blog.betabong.com/2008/08/22/flash-player-10-i-love-speed/' rel='bookmark' title='Permanent Link: Flash Player 10 – I love speed'>Flash Player 10 – I love speed</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Yesterday I had a presentation at the <a href="http://www.sfug.ch/?p=123">SFUG meeting</a> covering some bits of my rewritten BBML framework (originated from the project laax.com). I&#8217;ve tried to share some insights into the technical concept and strategies for CSS parsing, <a href="http://en.wikipedia.org/wiki/CSS_selector">CSS selectors</a> and layout validation.</p>
<p><img src="http://blog.betabong.com/wp-content/uploads/2009/04/sfug-pres.jpg" alt="Sev presenting..." title="Sev presenting..." width="520" height="390" class="alignnone size-full wp-image-266" /><br />
<small>Picture by <a href="http://www.entropy.ch/about/welcome.html">Marc Liyanage</a></small></p>
<p>It&#8217;s been surprisingly fun (I give credits to the beer sponsored by <a href="http://www.nemos.ch/">Nemos</a>). People even managed to pretend they&#8217;d be interested in what I was prosing, so credit to them too!</p>
<p><a href="http://www.flashatthelake.ch" style="float: right; display: block; margin-left: 10pt; margin-bottom: 10pt;"><img src="http://fatl.ch/banners/fatl_button3_120x60.gif" width="120" height="60" hspace="10" vspace="10" border="0" alt="Flash at the lake Swiss Flash User Group Conference." /></a> I&#8217;d also like to mention that there&#8217;ll be <strong>the</strong> swiss flash event soon: Flash at the Lake will not only pamper you with appearances of <a href="http://fatl.ch/?page_id=16">great national and international Flash enthustiacs</a>, it will also give anybody attending the pleasure to enjoy one of Zurich&#8217;s greatest locations with people who don&#8217;t think of you as a storm lightning adorer when you sit in the sun twittering Flash into the clear lake. And all that to a fantastic price. Check it out at <a href="http://fatl.ch">fatl.ch</a></p>
<p>So here we go with the presentation (<a href="http://www.apple.com/quicktime/download/">Quicktime</a> so you can enjoy the marvelous effects):</p>
<p><object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="520" height="390"><param name="src" value="/wp-content/uploads/2009/04/sfug-presentation-bbml-hq.mov" /><param name="controller" value="true" /><param name="autoplay" value="false" /><param name="scale" value="aspect" /><object type="video/quicktime" data="/wp-content/uploads/2009/04/sfug-presentation-bbml-hq.mov" width="520" height="390">
<param name="autoplay" value="false" /><param name="controller" value="true" /><param name="scale" value="aspect" /></object></object></p>


<p>Related posts:<ol><li><a href='http://blog.betabong.com/2008/08/22/flash-player-10-i-love-speed/' rel='bookmark' title='Permanent Link: Flash Player 10 – I love speed'>Flash Player 10 – I love speed</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.betabong.com/2009/04/22/bbml-presentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simplicity follows Performance – parsing Strings in Actionscript 3</title>
		<link>http://blog.betabong.com/2008/09/01/speed-parsing-string-in-as3/</link>
		<comments>http://blog.betabong.com/2008/09/01/speed-parsing-string-in-as3/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 16:18:25 +0000</pubDate>
		<dc:creator>betabong</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[speed]]></category>

		<guid isPermaLink="false">http://blog.betabong.com/?p=101</guid>
		<description><![CDATA[In my current project I do a lot of String parsing. Much a lot! And when it comes to do the same things many many times, performance will gain much from little details.
Let&#8217;s take the simplest parsing as an example. Converting a CSS like string &#8220;width: 100%; maxwidth: 500; fontface: Bold; gap: 10;&#8221; to an [...]


Related posts:<ol><li><a href='http://blog.betabong.com/2009/09/22/binary-fun-bits-in-bed-with-actionscript/' rel='bookmark' title='Permanent Link: Binary Fun &#8211; Bits in Bed with Actionscript'>Binary Fun &#8211; Bits in Bed with Actionscript</a></li><li><a href='http://blog.betabong.com/2008/07/21/nested-inner-functions-can-be-evil/' rel='bookmark' title='Permanent Link: Nested inner functions can be evil'>Nested inner functions can be evil</a></li><li><a href='http://blog.betabong.com/2009/04/13/metatunnel-1k-demo-as-vs-js/' rel='bookmark' title='Permanent Link: Metatunnel 1k Demo: AS vs. JS'>Metatunnel 1k Demo: AS vs. JS</a></li></ol>]]></description>
			<content:encoded><![CDATA[<p>In my current project I do a lot of String parsing. Much a lot! And when it comes to do the same things many many times, performance will gain much from little details.</p>
<p>Let&#8217;s take the simplest parsing as an example. Converting a CSS like string <strong>&#8220;width: 100%; maxwidth: 500; fontface: Bold; gap: 10;&#8221;</strong> to an object <strong>{ width: &#8220;100%&#8221; , maxwidth: &#8220;500&#8243; , fontface: &#8220;Bold&#8221; , gap: &#8220;10&#8243; }</strong></p>
<p>Compare these two methods to achieve this:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> simpleStringToObject_fast<span style="color: #66cc66;">&#40;</span> input : <span style="color: #0066CC;">String</span> , o : <span style="color: #0066CC;">Object</span> = <span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">Object</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> input == <span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">||</span> <span style="color: #66cc66;">!</span><span style="color: #0066CC;">Boolean</span><span style="color: #66cc66;">&#40;</span>input<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">return</span> o;
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> o == <span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">&#41;</span> o = <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>;
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> cursor : <span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>;
	<span style="color: #000000; font-weight: bold;">var</span> found_key : <span style="color: #0066CC;">String</span>;
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">index</span> : <span style="color: #0066CC;">int</span>;
	<span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> found_key == <span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">index</span> = input.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">':'</span> , cursor <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">index</span> <span style="color: #66cc66;">&amp;</span>gt;= <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span> input.<span style="color: #0066CC;">charAt</span><span style="color: #66cc66;">&#40;</span>index-<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #ff0000;">' '</span> <span style="color: #66cc66;">&#41;</span> index--;
				found_key = input.<span style="color: #0066CC;">substring</span><span style="color: #66cc66;">&#40;</span> cursor , <span style="color: #0066CC;">index</span> <span style="color: #66cc66;">&#41;</span>;
				cursor = <span style="color: #0066CC;">index</span> + <span style="color: #cc66cc;">1</span>;
				<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span> input.<span style="color: #0066CC;">charAt</span><span style="color: #66cc66;">&#40;</span>cursor<span style="color: #66cc66;">&#41;</span> == <span style="color: #ff0000;">' '</span> <span style="color: #66cc66;">&#41;</span> cursor++;
			<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #b1b100;">break</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">index</span> = input.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">';'</span> , cursor <span style="color: #66cc66;">&#41;</span>;
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">index</span> <span style="color: #66cc66;">&amp;</span>gt;= <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
				<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span> input.<span style="color: #0066CC;">charAt</span><span style="color: #66cc66;">&#40;</span>index-<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #ff0000;">' '</span> <span style="color: #66cc66;">&#41;</span> index--;
				o<span style="color: #66cc66;">&#91;</span> found_key <span style="color: #66cc66;">&#93;</span> = input.<span style="color: #0066CC;">substring</span><span style="color: #66cc66;">&#40;</span> cursor , <span style="color: #0066CC;">index</span> <span style="color: #66cc66;">&#41;</span>;
				found_key = <span style="color: #000000; font-weight: bold;">null</span>;
				cursor = <span style="color: #0066CC;">index</span> + <span style="color: #cc66cc;">1</span>;
				<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span> input.<span style="color: #0066CC;">charAt</span><span style="color: #66cc66;">&#40;</span>cursor<span style="color: #66cc66;">&#41;</span> == <span style="color: #ff0000;">' '</span> <span style="color: #66cc66;">&#41;</span> cursor++;
			<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
				o<span style="color: #66cc66;">&#91;</span> found_key <span style="color: #66cc66;">&#93;</span> = input.<span style="color: #0066CC;">substr</span><span style="color: #66cc66;">&#40;</span> cursor <span style="color: #66cc66;">&#41;</span>;
				<span style="color: #b1b100;">break</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> o;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> simpleStringToObject_slow<span style="color: #66cc66;">&#40;</span> input : <span style="color: #0066CC;">String</span> , o : <span style="color: #0066CC;">Object</span> = <span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">Object</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> input == <span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">||</span> <span style="color: #66cc66;">!</span><span style="color: #0066CC;">Boolean</span><span style="color: #66cc66;">&#40;</span>input<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">return</span> o;
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> o == <span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">&#41;</span> o = <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span>;
&nbsp;
	input = input.<span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">' '</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">join</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// remove spaces</span>
	<span style="color: #000000; font-weight: bold;">var</span> a : <span style="color: #0066CC;">Array</span> = input.<span style="color: #0066CC;">split</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">';'</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> pair : <span style="color: #0066CC;">Array</span>;
	<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>=<span style="color: #cc66cc;">0</span> ; i <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			o<span style="color: #66cc66;">&#91;</span> pair<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#93;</span> = pair<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #b1b100;">return</span> o;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>The first one might look like some crap lacking any elegance and style, but it&#8217;s<strong> twice as fast</strong> as the second one! And hey, if you do this a million times, it can be 5 seconds instead of 10. Might not seem to be that much, but I think it&#8217;s certainly <strong>worth the extra coding</strong> :-)</p>
<p>(Update: I haven&#8217;t mentioned RegExp here, though it definitely deserves a mention. Thing is that Regular Expressions are just damned slow in Flash compared to String manipulations, especially with longer strings. This is kind of surprising because it&#8217;s implemented natively. But the implementation obviously isn&#8217;t too good performance wise. I hope to see improvements with F10, though haven&#8217;t read anything about it yet &#8211; and also haven&#8217;t tested yet with beta. This little article confirms my experience with RegExp: <a href="http://www.mischel.com/diary/2006/07/12.htm">With a file of 10,000 lines, the string version is still instantaneous, but the regular expression version takes about five seconds.  Even with 180,000 lines, the string version is immediate.  We gave up on the regular expression version after over five minutes..</a>)</p>


<p>Related posts:<ol><li><a href='http://blog.betabong.com/2009/09/22/binary-fun-bits-in-bed-with-actionscript/' rel='bookmark' title='Permanent Link: Binary Fun &#8211; Bits in Bed with Actionscript'>Binary Fun &#8211; Bits in Bed with Actionscript</a></li><li><a href='http://blog.betabong.com/2008/07/21/nested-inner-functions-can-be-evil/' rel='bookmark' title='Permanent Link: Nested inner functions can be evil'>Nested inner functions can be evil</a></li><li><a href='http://blog.betabong.com/2009/04/13/metatunnel-1k-demo-as-vs-js/' rel='bookmark' title='Permanent Link: Metatunnel 1k Demo: AS vs. JS'>Metatunnel 1k Demo: AS vs. JS</a></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://blog.betabong.com/2008/09/01/speed-parsing-string-in-as3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
