<CFIF Len(myvariable) IS 0>
CF is a loosely typed language, so I'm not sure you could make any
assumptions about whether the above statement does a numeric or a string
comparison. My guess is that it's up to how well optimized the CF
interpreter is.
To be fairly certain, use <cfif not Len(myvariable)> or <cfif
Len(myvariable)>, where, after evaluating Len(), it then does a boolean
test - this is a simple "Is it zero?" operation, which is a low-level
hardware instruction on most CPU's.
Jim
-----Original Message-----
From: Dave Carabetta <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Tuesday, April 04, 2000 5:50 PM
Subject: The Len() function...Splitting Hairs?
>Hi all,
>I've been approached by a colleague to look into speed test results for
the
>following situation. I have been a member of this list for a long time
now
>and closely followed (and implemented) the suggestions for using the
Len()
>function as opposed to the <CFIF myvariable IS ""> method. However, is it
>quicker to use the following?
>
><CFIF Len(myvariable) IS 0>
>
>OK, I know the first reaction is "no way." At least, that's what mine
was!
>BUT, after thinking about it for a minute, i realized that the 0 is *not*
a
>string (because I am not using quotes around it), and in machine code,
the
>number 0 is all zeros, which a computer processes the fastest of any
>evaluation. Therefore, it would make sense to me that it is quicker for
the
>machine to process the zeros rather than having to search the results of
>"Len(myvariable)" for a 1, which would evaluate the statement to false. I
>realize that this might seem *extremely* tedious, but it does make a
>difference. If someone with the ability to do some load testing has a
second
>to run a comparison and post your results, I would be forever grateful. I
am
>always in search of ways to speed up my templates, no matter how
miniscule
>the improvement is!
>
>Regards,
>Dave Carabetta.
>Web Application Developer
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.