Speeding up array initialization
jbv
jbv.silences at Club-Internet.fr
Sat Nov 22 10:21:36 EST 2003
Hi there,
Let's say I have a variable S made of 100 lines of 100 items each,
and I want to initialize each item of each line to 0.
I can run the following script (which takes about 200 ticks on my
Mac G3/300) :
on mouseUp
put "" into S
repeat with j=1 to 100
repeat with i=1 to 100
put 0 into item i of line j of S
end repeat
end repeat
end mouseUp
If I want to speed up things, I can use the following script (which
takes less than 1 tick on the same Mac) :
on mouseUp
put 0 into S
repeat until number of items of S>=100
put "," & S after S
end repeat
put item 1 to 100 of S into S
repeat until number of lines of S>=100
put return & S after S
end repeat
put line 1 to 100 of S into S
end mouseUp
Now, I want to use a two-dimensional array instead of a variable.
To initialize each cell of the array to 0, I can run this script :
on mouseUp
put "" into S
repeat with j=1 to 100
repeat with i=1 to 100
put 0 into S[j,i]
end repeat
end repeat
end mouseUp
This script takes about 115 ticks.
QUESTION : is there a way to speed up things to initialize this array ?
Thanks,
JB
More information about the use-livecode
mailing list