Speed up a slow loop
J. Landman Gay
jacque at hyperactivesw.com
Wed Mar 2 21:19:59 EST 2022
On 3/2/22 7:44 PM, Jerry Jensen via use-livecode wrote:
> Instead of putting the keys into tCorrWdList and using
> “among the lines of tCorrWdList",
> how about using “among the keys of tCorrWdList”?
>
> Judging from no knowledge of the internals but guessing what it must do:
> “among the lines” has to look for all the line endings (unicode!),
> but “among the keys” can jump along by constant offsets since
> the keys are all fixed length hashes ?
> The lines happen to be all the same length, but “among the lines” can’t assume that and has to go look.
>
> Maybe I’m missing something again . . .
> .Jerry
Actually, this is what I do:
if sDictFile[L] = true then...
which I thought would be pretty fast since it's accessing the array directly. The array looks
like this:
sDictFile
word1 -> true
word2 -> true
word3 -> true
And my loop does this, for each user word:
if sDictFile["word2"] = true then...
so I'm not really looping through the keys, just looking for a matching one. The loop is for
each user word I need to find. If there's no key, then the word isn't legal. I hope that makes
sense.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list