Speed up a slow loop

Dick Kriesel dick.kriesel at mail.com
Sun Mar 6 15:33:12 EST 2022


> On Mar 2, 2022, at 1:57 PM, J. Landman Gay via use-livecode <use-livecode at lists.runrev.com> wrote:
> ...
> repeat for each line l in pList -- pList is the user word list
>    if sDictFile[l] = true then put l & cr after tCheckedList
>    else put l & cr after tNonWords
>    wait 0 with messages  -- prevent ANRs
>  end repeat
>
Hi, Jacque. If you use sets of words, as sDictFile already is, and as Ken suggested, then you can eliminate the repeat loop:

<code>
split pList by cr into tUserWords
intersect tUserWords with sDictFile into tChecked
difference tUserWords with sDictFile into tNonWords
</code>

Does that turn out to be fast enough for you?

— Dick




More information about the use-livecode mailing list