|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
05-23-2008 10:35
I've got a script I'm writing which merges two lists together, or more specifically, if the two lists are A and B, then B is merged into A. However, I have issues with memory usage and speed.
Now, for the majority of cases I think memory usage is fine, I've been using the list-memory hack to keep most operations good. But the main problem I'm having is in the case of where I'm inserting elements of B into list A (opposed to appending them).
My code does nothing complex, it decides where in A the result should go and then does an llListInsertList(). Now, my question is, are there any good ways to optimise list insertion?
For example, would I be better using a third list and appending items from A and B to it, rather than using llListInsertList? The main problem for me being that in a worst-case scenario I have to perform llListInsertList for every single element in B, which of course I'd rather not do =)
Anyone attempted similar problems and have any solutions that might be useful?
_____________________
Computer (Mac Pro): 2 x Quad Core 3.2ghz Xeon 10gb DDR2 800mhz FB-DIMMS 4 x 750gb, 32mb cache hard-drives (RAID-0/striped) NVidia GeForce 8800GT (512mb)
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
05-23-2008 11:14
I believe this should work:
A = llListInsertList((A=[])+A, B, pos);
|
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
05-23-2008 22:59
If you can append them and use llListSort, thats what I would recommend you do.
Something like: A = llListSort(((B = A = [])+ A) + B, 1, TRUE);
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river. - Cyril Connolly
Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence. - James Nachtwey
|
|
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
|
05-24-2008 04:18
Thanks for the suggestion Hewee, it solved the memory issue but unfortunately too many llListInsertList() calls are still killer on performance.
Cheers Strife for pointing me back to llListSort! After managing to make enough room to fit my A and B lists it is a much faster solution! Had to do a bit of fiddling to get it to sort my particular lists, but it works pretty well now. I have about 50 bytes free memory now but my memory usage never goes higher than that, though still can't wait for Mono =D
_____________________
Computer (Mac Pro): 2 x Quad Core 3.2ghz Xeon 10gb DDR2 800mhz FB-DIMMS 4 x 750gb, 32mb cache hard-drives (RAID-0/striped) NVidia GeForce 8800GT (512mb)
|