I don't have any exact figures. Ben Forta did a session on Advanced Tips 
and Tricks, and that was one of them.  It was related to the fact that a 
list is essentially a string, and ColdFusion has to read through that 
string to find the next delimiter.  Every time you wanted to access an 
element, it had to go through the list checking each character to see if it 
is the delimiter or not (at least that is my understanding.. I'll recheck 
my notes!)

One of the questions that was asked was whether it would be better to 
convert to an array and then work on the array until you were done, and 
then put it back out to the list... the answer to that was yes.   So if you 
must use lists, and need to do much work with them in a script, convert to 
an array first.

Lists are best used for Form results (ie, multiple selects) and in a SQL 
WHERE clause (ie, WHERE xx IN (#listname#)).  Arrays are faster than lists, 
but Structures are the fastest

And if you need to do much work with a single element (this goes for lists, 
arrays and struct), then copy that element out to a normal variable before 
doing anything else, and re-add it to the list when finished with it.

Maybe if I get the time, I'll go through all the notes I took and post a 
message of Tips and Tricks!!  There are lots of obvious ones..

1) Reduce the number of db calls, for example, use stored procedures and 
triggers, referential integrity (and CFTRY/CFCATCH to catch the database 
errors, this is quicker than letting CF process the forms for errors).

2) CFLOOP vs CFOUTPUT was another... CFLOOP is faster than CFOUTPUT... 
however, as a rule of thumb, if you are only listing fields from the 
recordset in CFOUTPUT, then use that.  If you are doing additional work, 
then use CFLOOP.

3) Use CFPARAM, rather than checking for Defined/Null.

4) Evaluate/DE are VERY intensive.  Use wisely!

5) Custom Tags are recommended over Includes because of the scope of 
variables... include files take the parent's scope, and so if you edit an 
include file, that is used on many pages, and add a new variable... results 
could be unpredictable if you have already used that same variable name 
elsewhere.

etc etc etc etc :^)

Nick



At 18:00 4/04/00 -0400, you wrote:
>Really!  That's the first I heard of that. I always thought that Lists would
>be faster.  I always see code where users convert list to arrays, and I
>would expect that would be more overhead.  Do you ( or anybody) have any
>more detail on performance gain of arrays over lists?
>
>
>Chris Evans
>[EMAIL PROTECTED]
>http://www.fuseware.com
>
>
>-----Original Message-----
>From: Nick Slay [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, April 04, 2000 5:24 PM
>To: [EMAIL PROTECTED]
>Subject: RE: Help: Can arrays be used like queries
>
>
>Hi Chris...
>
>Just thought I'd mention this tip that I picked up from ColdFusion-master
>Ben Forta at a developer conference a few weeks back....
>
>'Try and avoid using lists.  They are a lot slower than Array's or
>Structures.  They are easier to use, but at a cost to performance.'
>
>Regards
>
>Nick
>
>
>
>At 10:56 4/04/00 -0400, you wrote:
> >I always end up using lists rather than arrays, though a list can be
>thought
> >of as a 1-dimensional array.  So I would use a list of structures rather
> >than an array of structures.  I find Lists easier to create and maintain
> >than arrays.
> >
> >Chris Evans
> >[EMAIL PROTECTED]
> >http://www.fuseware.com
> >
> >
> >-----Original Message-----
> >From: Emily B. Kim [mailto:[EMAIL PROTECTED]]
> >Sent: Tuesday, April 04, 2000 10:39 AM
> >To: [EMAIL PROTECTED]
> >Subject: Re: Help: Can arrays be used like queries
> >
> >
> > >   You can also use queries as arrays.  For example, if I have a query
> >called
> > > "Articles" with a column named "TITLE", and I want the 5th
> > > row, I can use Articles.Title[5].
> >
> >just a fyi, although you can use array syntax to reference queries,
> >remember that queries are NOT arrays so you can't use the array
> >functions on them.
> >
> > > I rarely see a need for arrays with CF, though other programmers seem to
> >use
> > > them for everything.  I don't quite understand that.  I've seen a lot of
> > > programming, even custom tags, that translate native CF data elements
>into
> > > arrays, when it is easier to use the native data element.
> >
> >arrays are very useful for passing information without having to write
> >to the DB. think of use of an array of structures for a shopping cart.
> >-emily
> >---------------------------------------------------------------------------
>-
> >--
> >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.
> >
> >
> >---------------------------------------------------------------------------
>---
> >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.
>
>
>
>===========================================
>Nick Slay
>Technical Director
>
>Webbods Pty Ltd  (ACN 086 160 189)
>PO Box 4047
>Copacabana
>NSW 2251
>
>Tel:            02 4381 0284
>Mob:            0414 810284
>
>
>----------------------------------------------------------------------------
>--
>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.
>
>
>------------------------------------------------------------------------------
>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.

------------------------------------------------------------------------------
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.

Reply via email to