It's really interesting - to me - to see such attention to such 'small' language details in terms of performance. ColdFusion is the only language I've ever worked in where such small details made such big difference in speed... and now it seems it is only historical (which is code: CFML now behaves more like other languages).
On Thursday, Dec 5, 2002, at 22:07 US/Pacific, Michael Dinowitz wrote: > 1. There is no speed difference between using CFSET to set a variable > and using > CFSCRIPT to do so. This is true for setting a single variable as well > as setting > multiple variables. I prefer to use CFSCRIPT when setting multiple > variables as > I think it looks cleaner, but the choice is yours. It's all style. I'm amazed there was a speed difference before MX. I would have classed that as a bug in CF5. I agree on what looks cleaner. > 2. There is no difference between setting a variable to the value of > another > variable with or without pound signs. The following all work at about > the same > speed. > <CFSET name=url.name> > <CFSET name=#url.name#> > <CFSET name="#url.name#"> Again, I'm stunned that CF5 treated these differently - the compiler can statically determine these are identical and should generate identical code. > Again, the issue is proper formatting and style. This means that the > first CFSET > is the better one syntactically. Agreed. > 3. Setting a variable to a combination of text and dynamic data can be > done by > setting the dynamic data within the string OR by concatenating it all > together. > Both are about the same speed. > <CFSET time="The time is now "&timeformat(now())&" on > "&dateformat(now())&". > Your index is "&i> > <CFSET time="The time is now #timeformat(now())# on > #dateformat(now())#. Your > index is #i#"> Again, the compiler can figure this out so I'm surprised there was a speed difference before. > This is where things get tricky style wise. According to older styles > and most, > if not all of the authors (myself included), the first style is the > better one. I prefer the second style, even tho' the first style is more like other languages I've used. I find CF's in-string evaluation to be very elegant (and I'm glad that in MX there's no performance penalty!). > Bottom line is that almost anything done in the past to make a CFSET > faster is > now obsolete and the only reason to really use one type of CFSET over > another is > style and readability. Which is definitely good news! And it supports my view that readability is (generally) more important than performance. Code for readability and if - and only if - you find you have a performance problem, profile it and fix it. Sean A Corfield -- Director, Architecture Web Technology Group -- Macromedia, Inc. tel: (415) 252-2287 -- cell: (415) 717-8473 aim: seancorfield -- http://www.macromedia.com An Architect's View -- http://www.corfield.org/blog/ Introducing Macromedia Contribute. Web publishing for everyone. Learn more at http://www.macromedia.com/contribute ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.