|
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
|
03-16-2006 09:47
Another thread mentioned the difficulty with storing lists of avatar references - now I know that storing names is usually going to take less memory than storing IDs (if you can arrange things that you don't need the IDs), but can the name be clipped on the grounds that there are only so many surnames, so you might not need the whole thing to identify the user? Is there a full list somewhere of all SL surnames, even those that have been rotated out?
|
|
Kalleb Underthorn
Registered User
Join date: 30 Jul 2003
Posts: 40
|
03-16-2006 10:33
There is no real way of determining the 'minimum' number of characters for a surname, unforunately. The lindens add new ones all the time. If you want to reduce the memory requirements, my recommendation would be to take the Agent ID, strip the dashes, and convert from hex to integers. that would reduce it to about 16 bytes of total storage required per user (a little more if you use lists) IE: list KeyUnique( key id ) { string hex = "0123456789abcdef"; string source; integer x; integer y; integer v; list unique = [""]; source = llGetSubString( (string)id, 0, 7 ) + llGetSubString( (string)id, 9, 12 ) + llGetSubString( (string)id, 14, 17 ) + llGetSubString( (string)id, 19, 22 ) + llGetSubString( (string)id, 24, 35 ); for( x = 0; x < llStringLength(source); x+=8 ) { v = 0; for( y = 0; y < 8; y++ ) { v = v | (llSubStringIndex( hex, llGetSubString(source,x+y,x+y)<<  y*4))); } unique += [v]; } return unique; }
|
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
03-16-2006 12:53
If you're storing a LOT of names, you could do something like put the surnames in one list or string, and when you store a name store the first name and the offset of the surname: list surnames=[]; string short_name(string name) { list l = llParseString2List(name,[" "],[]); list sn = llList2List(l,1,1); if(0 != (integer)sn) // already a short name return name; integer i = llListFindList(surnames,sn); if(i == -1) { i = llGetListLength(surnames); surnames += sn; } return llList2List(l,0)+" "+(i+1); // use 1-origin for names so 0 is a sentinel }
string long_name(string name) { list l = llParseString2List(name,[" "],[]); integer sn = (integer)llList2String(l,1); if(0 == sn) // Already a long name return name; return llList2String(l,0) + " " + llList2String(surnames,i-1); }
Similar tricks with strings would be even more efficient.
|