Not really a huge surprise ... access to chunks such as 'item' and 'line' are (potentially) slow when you are searching relatively large strings. So the archetypal example

repeat with i = 1 to N
   get line i of tBigString
end repeat

can get slow if N is large, because of repeatedly scanning over large leading sub-strings to get to line 'i'.

In your case here, although we don't know how long the lines are (or how many items they have in them), the number of lines is very small  (i.e. line 1 up to line 4), so the amount of processing needed to scan/skip over the first few lines is very small - even though it's done often.

If you have some sample data, or gave some characteristics of the data, we could perhaps comment more.

-- Alex.


On 20/08/2018 10:00, jbv via use-livecode wrote:
Hi list,

I have the following script :

repeat with a = 1 to 34
  repeat with b = 1 to 10
   repeat with c = 1 to 11
    repeat with d = 1 to 10
     repeat with e = 1 to 34
      --get item a of line 1 of tvar & tab & item b of line 2 of tvar & tab
& item c of line 3 of tvar & tab & item d of line 4 of tvar & tab &
item e of line 5 of tvar
      --get T[1][a] & tab & T[2][b] & tab & T[3][c] & tab & T[4][d] & tab &
T[5][e]
     end repeat
    end repeat
   end repeat
  end repeat
end repeat

When I run these nested loops with the line "get item a of line 1 of
tvar...",
it is twice faster than with the line "get T[1][a]...".
This a surprise to me because I have used arrays for years to speed up
things, and AFAIK it takes forever to count items and lines at each repeat
iteration...
Or am I missing something ?
This is on LC9 server, on-rev account.

Best,
jbv


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to