Difference between revisions of "Talk:ParseString2List"
Jump to navigation
Jump to search
Line 10: | Line 10: | ||
==Optimized== | ==Optimized== | ||
<pre>list ParseString2List(string src, list separators, list spacers, integer ParseStringKeepNulls) | <pre> | ||
list ParseString2List(string src, list separators, list spacers, integer ParseStringKeepNulls) | |||
{//works just like llParseString2List and llParseStringKeepNulls | {//works just like llParseString2List and llParseStringKeepNulls | ||
//Instead of each list being limited to 8, it is now 1024. | //Instead of each list being limited to 8, it is now 1024. | ||
//The max length of src is 2,097,151 bytes. | //The max length of src is 2,097,151 bytes. | ||
integer i = ~(separators != []); | integer i = ~(separators != []); | ||
integer r = (spacers != []); | integer r = (spacers != []); | ||
Line 44: | Line 44: | ||
separators = llDeleteSubList(separators, i = llListFindList(keys, (list)r), i); | separators = llDeleteSubList(separators, i = llListFindList(keys, (list)r), i); | ||
if(~(test = llSubStringIndex(src, p))) | if(~(test = llSubStringIndex(src, p))) | ||
separators = | separators += ((test + offset) << 11) | (r & 0x7FF); | ||
} | } | ||
if(src != "" || ParseStringKeepNulls) | if(src != "" || ParseStringKeepNulls) |
Revision as of 23:07, 18 September 2007
Hi Strife,
you did a really good job with this contribution. I just added a description of this script to 'LSL Script Library' section in Category 'LSL Library', but stumbled over this entry's name.
Why didn't you just name it 'ParseString2List' according to the standard naming conventions for functions?
Greetz --Huney Jewell 04:02, 18 September 2007 (PDT)
- Not really sure, was pretty tired by the time I made that contribution. The function naming standard is a bit informal. Seemed like a good idea at the time... which was after having spent many hours on a jet. I wrote it and posted it while I should have been packing for my trip last week, thanks for putting it in the library. -- Strife Onizuka 21:22, 18 September 2007 (PDT)
Optimized
list ParseString2List(string src, list separators, list spacers, integer ParseStringKeepNulls) {//works just like llParseString2List and llParseStringKeepNulls //Instead of each list being limited to 8, it is now 1024. //The max length of src is 2,097,151 bytes. integer i = ~(separators != []); integer r = (spacers != []); integer offset = 0xFFF00000;//doubles the max length of src spacers += separators; list out = "" + (separators = []);//saves 1 byte. integer test; string p; while((i = -~i) < r) if(!~llListFindList(out, (list)(p = llList2String(spacers, i)))) if(~(test = llSubStringIndex(src, p))) { separators = separators + (((test + offset) << 11) | (i + 0x400)); out += p; } out = []; while(separators) { p = llList2String(spacers, (test = (0x7FF & (r = llList2Integer(separators = llListSort(separators, 1, TRUE), 0)))) - 0x400); if(offset <= (i = (r >> 11))) { if(offset ^ i || ParseStringKeepNulls) out += llDeleteSubString(src, i - offset, -1); if(test & 0x400) out += p; src = llDeleteSubString(src, 0, ~(offset - (i += llStringLength(p)))); offset = i; } separators = llDeleteSubList(separators, i = llListFindList(keys, (list)r), i); if(~(test = llSubStringIndex(src, p))) separators += ((test + offset) << 11) | (r & 0x7FF); } if(src != "" || ParseStringKeepNulls) out += src; return out; }//Strife Onizuka