We are talking about CFMX right? Not CF5, in CF5, <cfif Len(trim(str))> is faster empty or not ...right?
Paul Giesenhagen QuillDesign > 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 > > ______________________________________________________________________ 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/[email protected]/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

