How to use an array to solve the following...

Geoff Canyon Rev gcanyon+rev at gmail.com
Mon Feb 20 21:20:33 EST 2012


Certainly correct, but there is not the tremendous performance advantage to
using "for each element in..." For items, lines, and words, using
"item/line/word of myContainer" gets worse the larger the container is. For
character and with arrays, it doesn't. In my quick testing here, there's
just about no performance advantage to doing repeat for each element.
There's about a 4x benefit for using "repeat for each char" over "repeat
with i = 1 to length(myString)" But note that it seems to be 4x regardless
of the string length. That isn't the case with items, lines, and words --
there, the longer your container, the more you'll suffer.


On Mon, Feb 20, 2012 at 3:02 PM, Bob Sneidar <bobs at twft.com> wrote:

> Also each element in <array>
>
> Bob
>
>
> On Feb 20, 2012, at 10:34 AM, gcanyon+rev wrote:
>
> > any time you find yourself writing:
> >
> > repeat with i = 1 to the number of lines|words|items of someContainer
> >
> > stop. Rewrite it as:
> >
> > repeat for each line|word|item in someContainer
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list