<?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: Order of Enum in Case Statement</title>
	<atom:link href="http://www.davinciunltd.com/2008/07/order-of-enum-in-case-statement/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.davinciunltd.com/2008/07/order-of-enum-in-case-statement/</link>
	<description>Jim McKeeth's blog on creative and innovative Delphi programming.</description>
	<lastBuildDate>Wed, 01 Feb 2012 16:40:53 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Thaddy de Koning</title>
		<link>http://www.davinciunltd.com/2008/07/order-of-enum-in-case-statement/comment-page-1/#comment-208</link>
		<dc:creator>Thaddy de Koning</dc:creator>
		<pubDate>Mon, 14 Jul 2008 08:28:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.davinciunltd.com/2008/07/order-of-enum-in-case-statement/#comment-208</guid>
		<description>Although the compiler always optimizes a case loop to be in-order,
Olivier is right: You also need to watch your algoritm.

That also implies that when you know some code is more likely to occur than other code in the case loop, you need to enforce it by evaluating from a low (the lowest) const value.

But that assumes the compiler will optimize from low to high, and that may not be the case: the compiler may also optimize high to low....
Some compilers do...

All in all, Olivier: it is pretty dangerous to rely on perceived optimizations that you can not be sure about and maybe version dependent.
In your case: you can better write out your algoritm in such a way that the optimization you want is enforced, i.e.  f.e. by evaluating the most commonly encountered code first by means of if/then.../else /case/endcase</description>
		<content:encoded><![CDATA[<p>Although the compiler always optimizes a case loop to be in-order,<br />
Olivier is right: You also need to watch your algoritm.</p>
<p>That also implies that when you know some code is more likely to occur than other code in the case loop, you need to enforce it by evaluating from a low (the lowest) const value.</p>
<p>But that assumes the compiler will optimize from low to high, and that may not be the case: the compiler may also optimize high to low&#8230;.<br />
Some compilers do&#8230;</p>
<p>All in all, Olivier: it is pretty dangerous to rely on perceived optimizations that you can not be sure about and maybe version dependent.<br />
In your case: you can better write out your algoritm in such a way that the optimization you want is enforced, i.e.  f.e. by evaluating the most commonly encountered code first by means of if/then&#8230;/else /case/endcase</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Lehmann</title>
		<link>http://www.davinciunltd.com/2008/07/order-of-enum-in-case-statement/comment-page-1/#comment-206</link>
		<dc:creator>Daniel Lehmann</dc:creator>
		<pubDate>Sun, 13 Jul 2008 15:33:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.davinciunltd.com/2008/07/order-of-enum-in-case-statement/#comment-206</guid>
		<description>A while ago I did a similar test and wrote down my results here:

http://www.delphipraxis.net/topic41187_delphiinternals+compilerverhalten+bei+case+statements.html&amp;highlight=


You should be able to read German, though ;)


Regards
Daniel</description>
		<content:encoded><![CDATA[<p>A while ago I did a similar test and wrote down my results here:</p>
<p><a href="http://www.delphipraxis.net/topic41187_delphiinternals+compilerverhalten+bei+case+statements.html&amp;highlight=" rel="nofollow">http://www.delphipraxis.net/topic41187_delphiinternals+compilerverhalten+bei+case+statements.html&amp;highlight=</a></p>
<p>You should be able to read German, though <img src='http://www.davinciunltd.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Regards<br />
Daniel</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Olivier Beltrami</title>
		<link>http://www.davinciunltd.com/2008/07/order-of-enum-in-case-statement/comment-page-1/#comment-205</link>
		<dc:creator>Olivier Beltrami</dc:creator>
		<pubDate>Sun, 13 Jul 2008 06:26:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.davinciunltd.com/2008/07/order-of-enum-in-case-statement/#comment-205</guid>
		<description>I think the issue is if the order matters with respect to the most probable cases. That is to say if your enum has options a-b-c and 90% of the time it is option a, then you should put the code for option a first.</description>
		<content:encoded><![CDATA[<p>I think the issue is if the order matters with respect to the most probable cases. That is to say if your enum has options a-b-c and 90% of the time it is option a, then you should put the code for option a first.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

