1 more speed question

MisterX b.xavier at internet.lu
Wed May 18 15:18:46 EDT 2005


Mark,

if in your repeat loop you just use line 1 of container,
then delete it (from a tempList) then you'll see it's just
as fast...

repeat 1000
get line 1 of mylist
delete line 1 of mylist

cheers
Xavier 

> -----Original Message-----
> From: use-revolution-bounces at lists.runrev.com 
> [mailto:use-revolution-bounces at lists.runrev.com] On Behalf Of 
> Mark Smith
> Sent: Wednesday, May 18, 2005 20:05
> To: use-revolution at lists.runrev.com
> Subject: Re: 1 more speed question
> 
> I put this in the script of a button:
> 
> on mouseUp
>    repeat 10000
>      add 1 to c
>      put c & cr after theList
>    end repeat
> 
> 
>    put the milliseconds into stTime
>    repeat for each line L in theList
>      get L
>    end repeat
>    put the milliseconds - stTime into forTime
> 
>    put the milliseconds into stTime
>    repeat with n = 1 to the number of lines in theList
>      get line n of theList
>    end repeat
>    put the milliseconds - stTime into withTime
> 
>    put forTime && withTime
> end mouseUp
> 
> forTime was 7, with time was 1197.
> 
> My understanding of the issue is that in the 'with' 
> construction, the lines have to counted from 1 to get the 
> line you want, each time round. 
> With a short list, this is not a problem, but when it's got 
> to count thousands of lines (increasing by 1 everytime), it 
> can get slow. The 'for' construction is effectively keeping a 
> running tally of where it's got to, so is only having to add 
> 1 each time. Also, the 'get L' above is redundant, since L 
> already contains the data of whichever line it's got to.
> 
> Imagine having to count from 1 to 9000, then 1 to 9001, 1 to 
> 9002 etc. 
> as opposed to simply counting from 1 to 10000.
> 
> Cheers,
> 
> Mark




More information about the use-livecode mailing list