remove empty lines
Mark Smith
mark at maseurope.net
Thu Aug 3 06:44:57 EDT 2006
What were your results? On this machine (Mac PB 1.5mhz) I got:
10000 lines in a field with approx. 1000 randomly placed empty lines
put fld text into variable, repeat for each, place new list into fld
-- 78 millisecs
put fld text into variable, filter variable, put back into field --
72 millisecs
simply filter field -- 70 millisecs
So not a huge difference between any of them.
Best,
Mark
On 3 Aug 2006, at 05:42, Richard Gaskin wrote:
> Alex Tweedly wrote:
>
>> ... you could do it like
>>> put fld 'emailList' into tEmailList
>>> put empty into tNewEmail
>>> repeat for each line tEmail in tEmailList
>>> if line tEmail is not empty then
>>> put tEmail & CR after tNewEmailList
>>> end if
>>> end repeat
>>> put tNewEmailList into fld 'emailList'
>> but easier would be
>>> put fld 'emailList' into tEmailList
>>> filter tEmailList without empty
>>> put tEmailList into fld 'emailList'
>
> Easier to script, yes, but note the result from running this script
> which compares both methods:
>
>
> on mouseUp
> put 1000 into N
> put fld 1 into tData
> --
> --
> -- 1. repeat for each
> --
> put the millisecs into t
> repeat N
> --
> put empty into R1
> repeat for each line tLine in tData
> if tLine is not empty then
> put tLine &cr after R1
> end if
> end repeat
> delete last char of R1
> --
> end repeat
> put the millisecs - t into t1
> --
> --
> -- 2. filter:
> --
> put the millisecs into t
> repeat N
> --
> put tData into R2
> filter R2 without empty
> --
> end repeat
> put the millisecs - t into t2
> --
> --
> -- Result:
> put t1 && t2
> end mouseUp
>
>
> Did I write this wrong?
>
> Seems most times I benchmark "repeat for each" with the well-
> optimized "put after" I get results that hold up surprisingly well.
>
> I have another post in the works with some other interesting
> benchmarks related to processing lists (things I learned on summer
> vacation <g>)...
>
> --
> Richard Gaskin
> Managing Editor, revJournal
> _______________________________________________________
> Rev tips, tutorials and more: http://www.revJournal.com
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list