Speed up a slow loop

Alex Tweedly alex at tweedly.net
Sun Mar 6 14:43:11 EST 2022


Another thought on this problem; I think worth discussing even if the 
various suggestions so far have already got you a solution. I think it's 
a general observation ...

You don't really care how long it takes to do this.
What you care about is how long the user has to wait for your (the 
app's) response.

So don't wait until the user has found all their possible words (i.e. 
the app is doing effectively nothing for the 30 seconds or so that the 
user gets for each board). Check each word as they type it, and store 
the result. Then, when the 30-sec timer is up, you will have only one or 
two last words to test - all the others have already been checked.

So you never care about how long it takes to check 50 or so words 
against the dictionary - you check 49 of them one-at-a-time during the 
time you are otherwise idle. And the user has only to wait for the 
negligible delay while you check one or two words.


Alex.




More information about the use-livecode mailing list