> I need to quickly lookup items in a struct, in which > there's a 10% chance that the key will not exist. Offhand, > does anyone have an idea which would be faster: Using > StructKeyExists() first, then using StructFind() (or an > associative-array style construct) if the first function > is true, or just using StructFind() and trapping the > exception generated if the key doesn't exist? Seems the > first method requires CF to search the struct for the key > twice 90% of the time, unless CF somehow caches the lookup. > But I have no idea how much of a penalty throwing and > catching the exception 10% of the time might be.
In general, exception handling imposes little overhead, especially when no exception is thrown. However, my guess - and this is just a guess - is that the difference between the two will probably be trivial. If you're that interested, though, I doubt that anyone can give you a definitive answer, so your best bet is to simply test it yourself. You might even report your answer back here! Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ voice: (202) 797-5496 fax: (202) 797-5444 ______________________________________________________________________ Why Share? Dedicated Win 2000 Server � PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation � $99/Month � Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc 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

