> "and cfml list loop is even more efficient than array..."

> WOW!... There must be something really wrong with the CFMX
> Implementation of
> Arrays.
> That is completely backwards to Java Implementation. Bruce
> Eckel's (Thinking
> in Java)
> compares the Collection Classes and i believe mentions...

> There is No Collection to beat "Primitive Java Arrays"
> Performance.

> So what are we dealing with here? Coding backwards? Or We
> need Primitive
> Data Types in CFMX?

> Joe Eugene

Under the hood <cfloop index="x" list="a,b,c"> probably converts this
list to a primative array and procedes to call the loop contents
against each element in that array...

By comparison, when you have this in your cfml

myarray = listtoarray("a,b,c");
for (x = 1; x lte arraylen(myarray); x = x + 1) {
i = myarray[x];
blah blah...
}

produces somewhat different java code when it's compiled... the
results of the first line is probably included in the list loop
implementation, but then the cfml compiler doesn't _know_ that you're
just going to loop over that array, so it doesn't make any assumptions
and it moves on to the next item which is a for-next loop (separate
from the array), so it checks the array length once on each iteration
of the loop and each time you request myarray[x] it goes back to the
array to fetch the data.

By comparison, the list loop already knows internally, so it only has
to tokenize the list once and it only has to go to the array to get
the value from it once per iteration of the loop.

So no, it's not bad code -- the cfml compiler is generating code on on
the basis of all the information it has available, and with the list
loop it has a bit more information available "up-front", so it's able
to do more with it internally without having to "go back to the cfml"
to get more info.

In essence, the list loop is the most efficient implementation of the
"Primative Java Array" whereas a CFML array loop is not. It's all in
the need to compile a second language.

s. isaac dealey     954.927.5117
new epoch : isn't it time for a change?

add features without fixtures with
the onTap open source framework

http://www.sys-con.com/story/?storyid=44477&DE=1
http://www.sys-con.com/story/?storyid=45569&DE=1
http://www.fusiontap.com
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to