Speed

Jan Schenkel janschenkel at yahoo.com
Wed Sep 18 05:36:01 EDT 2002


Hi Jim,

It has everything to do with the optimisation RR/MC
can apply to the "repeat for each line" statement: the
engine knows that it will have to fetch the next line,
starting from the position in memory its internal
repeatFor-pointer is currently at.
If you use "repeat with i = 1 to the number of lines"
then the engine will have to search line i back from
the beginning of the variable, effectively going
through lines 1, 2, ..., i-1 in order to find the
contents of line i.

Splitting the variable into an array also helps,
because RR/MC can immediately jump to the point in
memory where anArray[i] is, instead of having to wade
through lines 1, 2, ..., i-1 in order to find the
contents of line i.
So in those cases where "repeat for each line" is
impractical, you can indeed get a serious speed-bump
by turning the variable into an array with a simple
  split aVariable by return

Hope this cleared things up a bit,

Jan Schenkel.

"As we grow older, we grow both wiser and more foolish
at the same time."  (De Rochefoucald)

--- Jim Hurley <jhurley at infostations.com> wrote:
> This is a postscript to my previous message
> regarding speed.
> 
> I'm embarrassed to say there is a simple way to
> employ "repeat for 
> each line..." and the difference in speed is
> profound.
> 
> But I would nevertheless like to understand why
> "repeat with i = 1 to 
> the number of lines in...." is so much slower and
> whether putting the 
> list of lines in an array is the better way to go in
> those situations 
> where "repeat for each...." is not practical.
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
>
http://lists.runrev.com/mailman/listinfo/use-revolution


__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com



More information about the use-livecode mailing list