Speed testing: Fastest search method

David Epstein dfepstein at comcast.net
Mon Sep 1 11:31:48 EDT 2014


Thanks to jbv at souslelogo.com for the suggestion that hasMemory(bytes)  
might be useful.  I haven't tried this yet.

Thanks to  <admin at FlexibleLearning.com> for replies to my other  
questions.

On the memory cost of writing fld "data" to tVar

> Q2. Of course it does, but the same condition is in place in all three
> tests. And the data has to come from somewhere.

My question was whether we could save memory (and if there is some  
other downside) if we write

> repeat for each line L in fld "data"

rather than

> put fld "data" into tVar
> repeat for each line L in tVar

On the rules about "repeat for":

> Q2. This 'repeat for each' rule refers to not modifying whatever  
> 'each'
> refers to. In this case, 'each' is a line and the number of lines in
> unchanged so I am not changing the internal line pointers set up by  
> the
> engine at the start.

If your approach works consistently, it implies that LiveCode's  
dictionary is too restrictive when it says (regarding "repeat for  
each labelVariable in container"):

"Important! In any of the for each loops, you should not change the  
labelVariable or container in a statement inside the loop. Doing so  
will not cause a script error, but will almost certainly produce  
unexpected results."

David Epstein




More information about the use-livecode mailing list