Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

More Memory vs. Higher Accuracy

Cypher Ragu
[Mad Scientist]
Join date: 6 Jul 2008
Posts: 174
02-27-2009 22:01
Hello everyone.

I recently created an inventory management script that can be used by multiple people. It works perfectly, except for one thing...

I have it check its lists for null values every now and then, and delete them from the list if any are found. I do this by converting the list to a string and then parsing it back into a list. I just realized, however, that this sometimes causes the lists to become out-of-sync with each other. Since it's critical that the users of this script can store their objects safely, I had to remove the ListWithoutNulls function.

Do null values in lists take up any memory? If so, how much? If it's a significant amount, should I put back the ListWithoutNulls function but have it check to make sure the lists will stay in-sync?


Thanks in advance ^_^
_____________________
Life is a highway... And I just missed my exit.
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
02-28-2009 02:05
From: Cypher Ragu
I have it check its lists for null values every now and then, and delete them from the list if any are found. I do this by converting the list to a string and then parsing it back into a list. I just realized, however, that this sometimes causes the lists to become out-of-sync with each other.
Tell me, why do you have to parse it to a string and back? Why not search the list for NULL values and remove them?
The Remove should be easy to synchronize for more lists.
LSL has excellent functions for searching lists and for removing sub lists:)
_____________________
From Studio Dora
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
02-28-2009 04:24
Why are nulls getting placed in your list in the first place?
_____________________
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
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
02-28-2009 09:55
From: Cypher Ragu
Do null values in lists take up any memory? If so, how much?

yes, Link:http://wiki.secondlife.com/wiki/LSL_Script_Memory

when you say nulls, do you mean actual nulls, or null references to objects no longer in it's inventory? if it's the latter, some kind of cleanup should prevent this, by checking either specific objects rezzed, or by running a match sweep when inventory changes (note, I don't think name changes within inventory trigger a changed event)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
02-28-2009 09:56
From: Strife Onizuka
Why are nulls getting placed in your list in the first place?

That was my thought. At any place where a NULL might be stored, you have an opportunity to do clean up right there on the spot. Sometimes it might not be desirable and most cost more than it saves, but it is certainly an option to consider.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
02-28-2009 10:04
From: Void Singer
[N]ote, I don't think name changes within inventory trigger a changed event

It is. I noticed a very long time ago however that, while the event is triggered if the script it is in changes name, llGetScriptName() doesn't report the result until some time after, so you have to insert some kind of sleep or timer event to see if the name has actually changed from the old one, and hope that your delay is long enough. :rolleyes: I reported this way back before JIRA existed for SL. Haven't revisited it since, but I highly doubt it has been fixed.

See http://www.lslwiki.net/lslwiki/wakka.php?wakka=changed
Cypher Ragu
[Mad Scientist]
Join date: 6 Jul 2008
Posts: 174
Two answer a few of your questions...
03-01-2009 20:59
Yes, they are actual null values. Empty strings, etc.

-----

The nulls aren't being added to the list, but rather replacing something that no longer exists.

I currently have two major lists. One for storing avatar's names/keys, and the other for storing the names of the items they've dropped into the object.

I use llListFindList to get the index of the user's name in the first list, which I can use to retrieve his items from the second list.

If he removes an item, that part of the list gets replaced with an empty string.

-----

I dump it to a string and parse it back just to make things easier for me :P

list RandomStuff = ["One", "Two," "Three", "", "Five"];
string temp = llDumpList2String(RandomStuff, "#";);

(temp = "One#Two#Three##Five)

list RandomStuffWithoutNulls = llParseString2List(temp, ["#"], []);

(RandomStuffWithoutNulls = ["One", "Two", "Three", "Five"])
_____________________
Life is a highway... And I just missed my exit.
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
03-02-2009 04:02
From: Cypher Ragu
I dump it to a string and parse it back just to make things easier for me :P

list RandomStuff = ["One", "Two," "Three", "", "Five"];
string temp = llDumpList2String(RandomStuff, "#";);

(temp = "One#Two#Three##Five)

list RandomStuffWithoutNulls = llParseString2List(temp, ["#"], []);

(RandomStuffWithoutNulls = ["One", "Two", "Three", "Five"])
I read you, you really make it hard on yourself;) Why not do it the easy way?
CODE
n=llListFindList( RandomStuff, [""]);
while (n>-1)
{
RandomStuffWithoutNulls = llDeleteSubList( RandomStuff, n, n );
...
another_list_synchronized = llDeleteSubList( another_list, n, n );
...
n=llListFindList( RandomStuff, [""]);
}
_____________________
From Studio Dora
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
03-02-2009 07:16
mispost
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
03-02-2009 09:03
Why not use a strided list and make life easy?
Cypher Ragu
[Mad Scientist]
Join date: 6 Jul 2008
Posts: 174
03-02-2009 09:21
From: Dora Gustafson
I read you, you really make it hard on yourself;) Why not do it the easy way?
CODE
n=llListFindList( RandomStuff, [""]);
while (n>-1)
{
RandomStuffWithoutNulls = llDeleteSubList( RandomStuff, n, n );
...
another_list_synchronized = llDeleteSubList( another_list, n, n );
...
n=llListFindList( RandomStuff, [""]);
}




O_o There's a DeleteSubList function?

*Slaps head*
_____________________
Life is a highway... And I just missed my exit.