Reverse a list

Mike Kerner MikeKerner at roadrunner.com
Tue Feb 17 15:11:34 EST 2015


Peter (Brett),

Help me with the chunking piece, then.

The following is very fast:
put "INSERT INTO sortTest VALUES :1" into tSQL
repeat for each line tLine in tDataSet
   revExecuteSQL dbid, tsql, tline
end repeat

The following is very slow:
put "INSERT INTO sortTest VALUES :1" into tSQL
put the number of lines in tDataSet into numLines
repeat with i = 1 to numLines
   revExecuteSQL dbid, tsql, line i of tDataSet
end repeat


So is randomly retrieving the chunk what makes this slow?  In the first
instance, how is that avoided - is it indexed?  If so, what is the overhead
of creating the index?  O(2n)?

On Mon, Feb 16, 2015 at 7:19 PM, Alex Tweedly <alex at tweedly.net> wrote:

> You were right first time ....
>
> if you use a reference, then there is no copy created when you do the
> call; and then you build up the output list.
>
> without the reference, there is an initial copy and then you additionally
> build the  output list.
>
> So using a reference parameter saves the memory for one copy (plus the cpu
> to create the copy).
>
> -- Alex.
>
>
>
> On 16/02/2015 23:06, Peter M. Brigham wrote:
>
>> I wrote:
>>
>>  I referenced the list and turned the function into a command, saves
>>> memory (possibly speed?) on very large lists.
>>>
>> I just realized that no memory is saved this way because we are building
>> a new duplicate (reversed) list within the command. So referencing the list
>> has no advantage.
>>
>> -- Peter
>>
>> Peter M. Brigham
>> pmbrig at gmail.com
>> http://home.comcast.net/~pmbrig
>>
>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



-- 
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."



More information about the Use-livecode mailing list