>- see footer for list info -<
Well, that's an entirely different discussion. In fact, I didn't even notice
his comment about how when comparing strings, an if/else would be faster.
That is indeed something that was recently discovered and demonstrated by
the folks at Webapper:

http://www.webapper.net/index.cfm?fuseaction=Fuseblog.ShowComments&ArticleID
=20060727042244

But I wasn't referring to performance at all. I was answering the question
that JGG had first posed: does it make sense to pay attention to the order
of CASEs? To that, all my argument has been, "no".

That said, as the blog entry shows, they found a 10-fold difference in
performance (worse) using cfswitch when the expressions were strings.

I only chose strings because it was what came to me first. JGG's original
note (left below, along with yours) doesn't talk about using strings,
though. So this whole discussion of performance of strings, while useful,
may not at all relate to what he's asking. 

/charlie
http://www.carehart.org/blog/

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Simon Baynes
Sent: Monday, August 07, 2006 1:48 PM
To: Coldfusion Development
Subject: Re: [CF-Dev] CFSwitch... Aren't all cases evaluated?

>- see footer for list info -<
What Russ is trying to say is that if you are using Strings as your case
indicators

eg:
<cfswitch expression="#myVar#>
<cfcase value="Simon">
<!--- do something --->
</cfcase>
<cfcase value="Baynes">
<!--- do something else --->
</cfcase>
</cfswitch>

Then it will be slower than replacing that with an if-elseif-else
equivalent. This is because in Java you cannot do the above as a switch
statement can only be against a numeric value. So ColdFusion achieves this
by trying it and if it throws a runtime exception it then converts it to an
if-elseif-else equivalent.

This may well explain why it gives a compile time error and does not
necessarily support your assumption that:-

"the fact that it doesn't permit a duplicate value tells me it is"

Regards,

Simon

<snip>

> > *From:* "Jolly Green Giant" <[EMAIL PROTECTED]>
> > *To:* [email protected]
> > *Date:* Sun, 6 Aug 2006 23:07:50 -0400
> >
> > >- see footer for list info -<
> > I'm studying for my certification.  Forta, in the study book, says 
> > that "like cfif, you should put the most popular cases at the top of 
> > the cfswitch block to improve performance.
> >
> > I thought one of the things was that all the cases were going to be 
> > evaluated anyway?  If they're all evaluated, then their location is 
> > no performance gain, right?
>

_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo

--
CFDeveloper Sponsors:-
>- Hosting provided by www.cfmxhosting.co.uk -<
>- Forum provided by www.fusetalk.com -<
>- DHTML Menus provided by www.APYCOM.com -<
>- Lists hosted by www.Gradwell.com -<
>- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<

Reply via email to