Basically 1 Line CODE VS 5 Lines CODE

-----Original Message-----
From: Michael Dinowitz [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 16, 2002 3:16 PM
To: CF-Talk
Subject: Re: Writing efficient CFIF statements


It is, but it's secondary to the IIF() speed problem itself. DE() only
compounds the problem with IIF() in CF 5. In MX, IIF() is the same as CFIF
so the only real difference will be the use of DE. For those who use proper
quoting, DE wouldn't be an issue so there will be no difference at all
between the two comparisons. Actually, no difference other than code
readability. :)
<CFIF isdefined('url.var') and url.var GTE 5>
    <CFSET mode="compact">
<CFELSE>
    <CFSET mode="open">
</CFIF>
OR
<CFSET mode=IIF(isdefined('url.var') and url.var GTE 5, '"compact"',
'"open"')>
The CFIF version looks easier to read for most CF programmers while the IIF
version is shorter.

> Mike.
> Dont you think calling "DE" twice is additional overhead, even if its
> Minor?
> The less code/functions to the goal.. the faster, less buggy application
> you have..
> Isnt that what we learned in 101/102 "C" class.. just kidding!
> Joe
> Certified Advanced ColdFusion Developer
> [EMAIL PROTECTED]
>
> -----Original Message-----
> From: Michael Dinowitz [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 16, 2002 2:44 PM
> To: CF-Talk
> Subject: Re: Writing efficient CFIF statements
>
>
> While the while issue of DE verses staged quotes is an important one, the
> speed difference between IIF() and CFIF in CF 5 and earlier is separate
from
> that. DE adds very little overhead as it's just doing a fast replace on
> double quotes as well as surrounding its argument with double quotes. This
> is very little processing all in all. The problem has always been IIF()
> itself.
> The fact that IIF() and CFIF are the same speed in CFMX shows that the
> underlying comparison code for both is either the same thing or working
the
> same way.
>
>
> > I do strongly belive using the IIF right wouldnt be any slower than CFIF
> as
> > well
> > Eg.. The right usage
> > <cfloop index="x" from="1" to="10">
> > #x#.#IIF(x mod 2,"'odd'","'even'")#<br>
> > </cfloop>
> >
> > Improper usage which is any day going to be slower than CFIF
> > <cfloop index="x" from="1" to="10">
> > #x#.#IIF(x mod 2,DE("odd"),DE("even")#<br>
> > </cfloop>
> >
> >
> > Joe
> > Certified Advanced ColdFusion Developer
> > [EMAIL PROTECTED]
> >
> > -----Original Message-----
> > From: Michael Dinowitz [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, July 16, 2002 1:28 PM
> > To: CF-Talk
> > Subject: Re: Writing efficient CFIF statements
> >
> >
> > Actually, the main problem with using IIF() now is that few people know
> how
> > to use it right. The double evaluation issue, using DE vs. double
quoting,
> > etc. I'm going to have to revise my paper on it and get it out there
> again.
> > :)
> > http://www.fusionauthority.com/iif.cfm
> >
> >
> > > I wouldn't declare it dead for the sake of readability.  That above
> > > anything is a good reason not to use it.
> > >
> > > ~Todd
> > >
> > > On Tue, 16 Jul 2002, Michael Dinowitz wrote:
> > >
> > > > I really wish that people using my documents (originally posted in
> > issues of FA) put down where they got the information from. I see chunks
> of
> > information on that page taken directly from me.
> > > > Now as for IIS() under MX. I've tested it heavily and there is
> literally
> > no difference speed wise between IIF and CFIF. Counting on the run, you
> can
> > see the numbers change in the .001 millisecond range which is nothing at
> > all, especially as the numbers change for both and there is no clear
> > pattern.
> > > > That being said, I declare that the "best practice" of not using
IIF()
> > is dead as of MX.
> > > >
> > >
> > > --
> > > ============================================================
> > > Todd Rafferty ([EMAIL PROTECTED]) - http://www.web-rat.com/ |
> > >         Team Macromedia Volunteer for ColdFusion           |
> > > http://www.macromedia.com/support/forums/team_macromedia/  |
> > > http://www.flashCFM.com/   - webRat (Moderator)            |
> > > http://www.ultrashock.com/ - webRat (Back-end Moderator)   |
> > > ============================================================
> > >
> > >
> >
> >
>
>

______________________________________________________________________
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to