oops i didn't see the .id after the array, good catch.
I read page you suggested and it said:
livedocs said:
listGetAt() is not an efficient way to work with individual items in a data set!
however we were not working with a single element, and i also never believe anything about efficiency until i test it myself... i ran a test in cfmx 6.1
Code:
<cfset myArray = arrayNew(1)>
<cfloop from = "1" to = "10000" index = "count">
<cfset myArray[count] = count>
</cfloop>
<cfset foundInArray = false>
<cfset arrayTime1 = getTickCount()>
<cfloop from="1" to="#arrayLen(myArray)#" index="i">
<cfif myArray[i] EQ 54>
<cfset foundinarray = true>
[COLOR=gray]<cfabort>[/color]
</cfif>
</cfloop>
<cfif foundinarray>
found in array<br>
<cfelse>
not found in array<br>
</cfif>
<cfset arrayTime2 = getTickCount()>
<br>
<cfset listTime1 = getTickCount()>
<cfif listFind(arrayToList(myArray), "54")>
found in list<br>
<cfelse>
not found in list<br>
</cfif>
<cfset listTime2 = getTickCount()>
<cfset arrayTicks = (arrayTime2-arraytime1)>
<cfset listTicks = (listTime2-listTime1)>
<br>
<cfoutput>
searching the 10000 index array took #arrayTicks# ticks<br>
searching the 10000 index array using listfind(arraytolist(array),value) took #listTicks# ticks<br>
</cfoutput>
i found using listfind(arraytolist),value) was typically about 4 times faster than looping through the array.
using cfbreak once the number was found DID speed up the array loop though.
using cfbreak, looking for a small number like 54 took 0 ticks.
using cfbreak, looking for 7985 took an average of 47 ticks.
not using cfbreak the average took an average of 61 ticks to get any number looping over the entire array.
using listfind(arraytolist(array),value) took an average of 16 ticks no matter what number you were looking for.
to be fair livedocs also said "working with strings is slow in java."(way to go java) i added "a" after the numbers to make the data in each element a string not a number. my findings were the same.
If the automobile had followed the same development cycle as the computer, a Rolls-Royce would today cost $100, get a million miles per gallon, and explode once a year, killing everyone inside.