It would be fairer to compare Trim(emptyString) eq "" instead of emptystring eq "".
It's not fair to say that 'eq ""' is simpler than len(trim(nonEmptyString)) when the second case is performing one extra optional function. > -----Original Message----- > From: Sean A Corfield [mailto:[EMAIL PROTECTED]] > Sent: Monday, 19 August 2002 3:19 p.m. > To: CF-Talk > Subject: Re: Best Practices > > > I noticed something odd in the test code below... > > On Friday, August 16, 2002, at 07:38 , Sean A Corfield wrote: > > On Friday, August 16, 2002, at 12:25 , Douglas Brown wrote: > >> <cfset myString = ""> > >> ... > >> <cfset myString = "1"> > > So the test of 'eq' is against an empty string but the test > of 'len()' is > against a NON-empty string. And these tests take different > times depending > on whether the string is empty or not. > > More research shows that in CFMX, emptyString eq "" is slower than > len(trim(emptyString)) by about 20% (remember we're talking > fractions of > milliseconds for a single expresssion!). > > However, for nonEmptyString eq "" and len(trim(nonEmptyString)), the > *former* is faster by about 20%! > > Given that most comparisons are likely to be against > non-empty strings, > this indicates that not only is the 'eq ""' test simpler, it is also > faster overall. > > Which means that in CFMX, <cfif str eq ""> is best practice > by both of the > definitions we've seen on the list. > > "If you're not annoying somebody, you're not really alive." > -- Margaret Atwood > > ______________________________________________________________________ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.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